Rsync Synchronization – Syncing Directories in Both Directions

rsyncsynchronization

I happen to know about rsyn, and I use rsync to sync between my mac and a linux server as follows.

rsync -r -t -v MAC LINUX
rsync -r -t -v LINUX MAC

I expected to run the first command to sync, but I needed the second command also when a change is made in LINUX.

Am I missing something? Does rsync have an option to sync between two directories?

Best Answer

You want bi-directional sync. Take a look at unison, which does this: http://www.cis.upenn.edu/~bcpierce/unison/

For example, on Debian/Ubuntu:

$ sudo apt-get install unison
$ unison MAC/ LINUX/

If you have trouble with permissions (example ext4 -> FAT):

$ unison -perms 0 vlc-2.2.0/ /media/sf_vlc/vlc
Contacting server...
Looking for changes
Reconciling changes

vlc-2.2.0      vlc                
new dir  ---->            /  [f] 

Proceed with propagating updates? [] y
Propagating updates