We have 2 Web Server node Primary and secondary, if the primary is down by any reason secondary will act as Prim.
Now if we talk about the codes we which is on both the host. we should be synchronizing it with actual primary data
How do we sync those codes?
I understand that rsync
can sync all the thing from the Live server to the secondary. but what about those changed which have deleted some file or folder, from live server rsync
should remove those from the secondary
As per my requirement can we use below rsync on my server. will this work
rsync -avzhe ssh user@server.example.com:/var/www/ /var/www
I tested this on my local system. no luck
[ar@test ~]$ rsync -avzhe /home/ar/avi/ /home/ar/red/
sending incremental file list
drwxrwxr-x 4096 2016/03/03 07:28:13 .
sent 51 bytes received 12 bytes 126.00 bytes/sec
total size is 0 speedup is 0.00
Solution
rsync -av --delete /home/ar/avi/ /home/ar/red/
rsync -avz /home/ar/avi/ /home/ar/red/
works fine. – AReddy Mar 03 '16 at 12:50rsync -av --delete /home/ar/avi/ /home/ar/red/
removes the file which is not present in the primary directory/home/ar/avi/
– AReddy Mar 03 '16 at 12:51