I mentioned in one previous post on how to do a physical to VM backup using simple Linux command. The method works pretty well as long as the kernel versions are kept in sync.

But for my Web server running WordPress,this backup method seemed to be an overkill. I use the following method to setup a standby WordPress server (can be either a VM or a physical machine). The backup server is always running and it’s content is synced up with the production server. In the event of a production server failure, all I need to do is to re-route the port 80 traffic to the standby server, which can be achieved in a matter of seconds.

To setup the standby server, I first installed Ubuntu server 8.04.1 (the same version as on my production server, with LAMP), and copied the WordPress content over (of course, most of the configurations need to be identical to the production server as well). To sync up the database content and the custom contents (e.g. uploaded images), the following command is scheduled to run on the server on a daily basis, which essentially backs up the content database:

mysqldump [wordpress db name] -p[password] >  /[backup directory root]/[backup file name]

 

on the standby server, the following commands are scheduled using cron daily to pick up the changes in production environment:

rcp [user name]@[production server]:[backup directory root]/[backup file name] ./dbbackup/
mysql -u[user name] -p[password] [wordpress db name] < ./dbbackup/[backup file name]
rcp -r [user name]@[production server]:/var/www/[wp installation dir]/wp-content/uploads /var/www/blog/wp-content

 

The above commands essentially restore the production database snapshot onto the standby server and sync up the custom contents.

One benefit of this hot sync technique is that the standby server is always live and can be tested readily by changing the host entry in /etc/hosts to point the production url to the standby server.

Be Sociable, Share!