Welcome Guest, Not a member yet? Register   Sign In
Sync live server and development server
#9

[eluser]jedd[/eluser]
Quote:Your description "a bash script that would export the DB, tar up the files, ftp them to the new server, untar and reimport" sounds like exactly what I need. The problem in this case is the 'how to'. I'm happy to study programming bash scripts, but I'm gonna need some pointers/ links to tutorials.

As the other J-man pointed out, bash scripts are fairly easy. Even if you don't realise it yet Wink

The big question is whether you can have any downtime on your boxes to do this stuff? MySQL can do hot backups, but I've always found them to be as slow as a wet week in August (Nothern Hemispherists should adapt this aphorism to taste).. Cold backups - where the DB is offline - are blindingly fast .. but obviously require the DB to be down. A lot depends on the complexity and size of the DB, of course.

If hot, you should google 'mysql hot backup' and then consider cold.

If cold, then it's easy - you usually stop the daemon, tar up the database, start the daemon. My script look like this:
Code:
#!/bin/bash
/etc/init.d/mysql  stop
tar cf - /var/lib/mysql  |  bzip2  --fast > /path/to/database.dump
/etc/init.d/mysql  start

And the middle line is only that complicated because I want to really minimise the downtime of the DB, and bzip is faster than gzip (tar natively supports the latter, not the former). I digress.

There's probably something to having regular backups of your production site anyway.


Quote:I've read something about rsync. Maybe you can point out a good resource for my situation to me?

I've met the bloke who wrote rsync, btw. Disturbingly smart guy.

If you can ssh directly into your development box, then it's really easy, because you can run the script on there and have it pull the data from production. Again, you may want to stage it locally, and do the copy from production --> local PC --> development box - as it gives you another backup on the local PC.

In any case, assume ssh to development is hunky dory, and my paths are all made up here, you'd run:

Code:
$  rsync  -av --delete  ssh.productionbox.com:/var/www/stuff/   /var/www/copyofstuff/

-a is the magic 'do everything you'd expect' option (retain permissions, recursive copy, etc)
-v is verbose - you'd turn that off if you didn't want to watch it (or you were scripting it)
--delete means that if it finds files on development that aren't on production any more, it'll delete them. It will NOT do anything to production, mind.


Messages In This Thread
Sync live server and development server - by El Forum - 03-25-2009, 03:45 PM
Sync live server and development server - by El Forum - 03-25-2009, 04:50 PM
Sync live server and development server - by El Forum - 03-25-2009, 05:20 PM
Sync live server and development server - by El Forum - 03-25-2009, 05:32 PM
Sync live server and development server - by El Forum - 03-25-2009, 05:38 PM
Sync live server and development server - by El Forum - 03-25-2009, 05:40 PM
Sync live server and development server - by El Forum - 03-25-2009, 05:47 PM
Sync live server and development server - by El Forum - 03-25-2009, 05:55 PM
Sync live server and development server - by El Forum - 03-25-2009, 06:16 PM
Sync live server and development server - by El Forum - 03-26-2009, 03:46 AM
Sync live server and development server - by El Forum - 03-26-2009, 05:24 AM
Sync live server and development server - by El Forum - 03-26-2009, 08:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB