I have ServerA and ServerB, ServerB was created from a snapshot of ServerA.
I want to be able to make changes (configurations, installed programs, files, db changes, etc.) on ServerA and then push those changes to ServerB when I am ready.
From ServerA I run this command:
rsync -avz -e ssh root@ServerB:/
The first thing I am told is:
Warning: the RSA host key for 'ServerB' differs from the key for the IP address '216.119.xxx.xxx' Offending key for IP in /root/.ssh/known_hosts:1 Matching host key in /root/.ssh/known_hosts:2 Are you sure you want to continue connecting (yes/no)?
I type in yes and hit return. I am prompted for root@ServerB's password, then it lists several files and finishes with this:
sent 7821 bytes received 1616926 bytes 47094.12 bytes/sec total size is 140739067508690 speedup is 86622143.33 rsync warning: some files vanished before they could be transferred (code 24) at main.c(1526) [generator=3.0.7]
But it did not sync.
I specifically put a file at /var/www/sync_test_file on ServerA and afterwards (I am expecting the file to now be on ServerB but) there is no such file in ServerB
Am I doing something wrong? Also, today is my first time ever using rsync.
I should warn you, syncing from the root of the file system as you are in your example is dangerous (you will override system-specific files that should probably not be overridden) and will probably be very slow (rsync must build a file list by walking the entire tree structure).
Your rsync command should specify both a source and a destination.
On serverA:
rsync -avze ssh / root@serverB:/
The RSA host key warning you see indicates that at some point root@ServerA knew about ServerB, and the IP address of ServerB has since changed. SSH warns you of this because you may be inadvertently sending/proxying your data through a rogue system. If you are certain you're not, you can simply remove the offending host key by editing /root/.ssh/known_hosts and removing the old line for ServerB.
The other error you get from rsync (about files vanishing) means that in the time it took rsync to generate its incremental file list and actually send the contents of one of those files, one or more of those files disappeared (deleted/moved). This can happen when you are syncing from a non-readonly/snapshotted file system. For the type of sync you are doing, it would be ideal if your filesystem or volume manager supported snapshotting so that you could take a snapshot of the file system at a point in time and sync it, without worrying about files getting deleted or moved around during the sync.