Comments on Mirror Your Web Site With rsync
This tutorial shows how you can mirror your web site from your main web server to a backup server that can take over if the main server fails. We use the tool rsync for this, and we make it run through a cron job that checks every x minutes if there is something to update on the mirror. Thus your backup server should usually be up to date if it has to take over.
9 Comment(s)
Comments
You should also add the parameter --numeric-ids to keep the value of the uid and gid of the file when its transfer.
As most websites these days are dynamic, you need to use different tools for mirroring.
I use wget to to create a mirror of my dyanmic pages.
I am mentioning rsync.net because I am a customer that wants to see their business thrive. Take a look at their philosophy and their privacy/warrant policy and you'll see why ...
I use rsync (and Unison, and sftp) to automatically backup my most important files to a 4 GB offsite filesystem at rsync.net, which they in turn replicate to their secondary loccation in Colorado.
It's a great solution. You should check them out.
About:
ssh-keygen -t dsa -b 2048 -f /root/rsync/mirror-rsync-key
DSA keys must be 1024 bits
ssh-keygen -t dsa -b 1024 -f /root/rsync/mirror-rsync-key
If you are using ssh on a non-standard port quote the ssh part of the commands and include the port option. For example...
rsync -avz -e 'ssh -p 8022' [email protected]:/var/www/ /var/www/
This is from around 1999 but still the very best rsync tutorial I've ever read: http://tinyurl.com/l37guv8
Thank you for the tutorial. I have port 22 closed for security reasons on the main server. How can I add another port into your script?
I can't get past this otherwise: rsync -avz -e ssh [email protected]:/var/www/ /var/www/
Thanks again!
the ssh command let's you specify a port with the -p flag. You can modify the script like so:
rsync -avz -e ssh -p 1234 [email protected]:/var/www/ /var/www/
rsync -avz -e "ssh -p 1243" [email protected]:/var/www/ /var/www/