rsync complication on sync

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 [email protected]:/var/www/ /var/www

I tested this on my local system. no luck

[<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6405162410011710">[email protected]</a> ~]$ 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/

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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/


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x