• I have server1 as production server.
  • I have server3 as failover server. Spun up from snapshot of server1.
  • I have server2 as filebackup server for server one. Role is to be the workhorse for supporting servers 1 and 3.

All three can talk to each other via ssh tunnel. All three are ubuntu 16.04 on digitalocean, each in a different region. MySQL database is installed to facilitate Wordpress site running in var/www/HTML. Likewise for php7 and nginx.

Two questions: Can I run rsync from server2 to keep server3 in sync with server1?

Since server3 is an identical twin of server 1, I want ALL changes on server1 synced to server3. Including system changes, software installs, content changes...all off it. The idea is to maintain server3 as identical to server1.

What then do I tell rsync to sync? Would it simply be server1/ to server3/ recursive?

Thank you for all input. I have reviewed all searches but could not see that these two specific questions have been addressed in the context of this configuration. Everything seems to deal with syncing only certain files or folders and not entire installations.

up vote 0 down vote accepted

I have successfully cloned a Linux system using rsync. I installed Ubuntu on a pendrive and cloned the OS from a laptop and the pendrive booted just fine. I also did it in two desktop computers. However, I once cp'ed /bin/, /lib, etc and it didn't work, I had to reinstall the target system, not sure why. But in general, it does work.

You need to exclude certain directories:

rsync -acv --delete --exclude=fstab --exclude=/dev --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/lost+found --exclude=/run --exclude=/sys --exclude=/tmp /server1/ /server2/

You need to exclude /etc/fstab because your UID's will be different in your servers. As /mnt and /media may contain custom directories that you created and need to be replicated in server2, make sure you can exclude them.

You also need to run sudo update-grub on the cloned system because /boot/grub/grub.cfg will point to the source OS's UID, which will be a problem when you reboot server2.

Before you do this in your production servers, make sure you test this procedure!

Also check this post: How to best clone a running system to a new harddisk using rsync?

  • Thanks much @John Z :) So far, I am considering using the following command from the workhorse server: ssh root@13.....144 "rsync -avxHAWX --numeric-ids --info=progress2 ssh / root@18.....33:/" Does the numeric id option help at all? – dwest100 Mar 2 '17 at 0:47
  • I don't use it because my backups are either constrained to one system or the users are the same in different systems. – John Z Mar 2 '17 at 19:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.