Rsync Synchronization – How to Achieve Bi-Directional Sync with Rsync

rsyncsynchronization

I am trying to setup bi-direction or two way sync with rsync. In my case I only need to delete the files when syncing from B to A. So, I was thinking of running rsync twice as follow :

rsync -rtuv ./A/ ./B/
rsync -rtuv --delete ./B/ ./A/

This problem with this solution is that when I run rsync (B->A) which would be right after running the rsync (A-B), Any new file that get created in between the sync will also get removed.

Is there a way I can specify a time stamp as condition that it only delete the file if it created before this date/time.

Updated:

I understand there is a unison solution but the problem with unison is required to install on both ends. I am syncing with a remote server and I can not install unison on the remote end.

Best Answer

You could try osync which is designed for exactly this task. I once set up a complex sequence of rsync commands to do the job, but I now use osync.

https://github.com/deajan/osync

It uses rsync internally, so it should be suitable for any situation where you could use rsync.

Related Question