0

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/

  • There seem to be nothing wrong. Verify the contents of the source directory on the server. – gerhard d. Mar 3 '16 at 12:46
  • rsync -avz /home/ar/avi/ /home/ar/red/ works fine. – Mongrel Mar 3 '16 at 12:50
  • rsync -av --delete /home/ar/avi/ /home/ar/red/ removes the file which is not present in the primary directory /home/ar/avi/ – Mongrel Mar 3 '16 at 12:51
  • So what's the problem you're trying to solve? I'm sorry, but it's just not clear (to me). – roaima Mar 3 '16 at 12:56
  • I'm just asking that will this work on the live ENV. – Mongrel Mar 3 '16 at 13:54
0

This command works for me, it gets sync with the live server and deletes the file which were deleted from the live server.

rsync -av --delete /home/ar/avi/ /home/ar/red/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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