2

user1 wants to do a bi-directional sync between 2 machines. user1 is a member of group2 and has a non-privileged ssh tunnel. There are lots of files and dirs such as:

rwxrwx--- userN group2  enclair/WEB/CLIENTS/VictorMarty

A few files get edited on both machines and need manual merging. Therefore I went with Unison rather than a rsync job on both sides.

unison's preference file:

perms = -1
#group = true
#owner = true
times = true

Bi-directional sync command I use:

$ unison "profile" -perms 0 -dontchmod

Output/result:

...
UNISON 2.48.3 finished propagating changes at 02:29:24.90 on 13 Sep 2015

Saving synchronizer state
Synchronization incomplete at 02:29:25  (0 items transferred, 1 skipped, 60 failed)

failed: enclair/WEB/CLIENTS/VictorMarty 

I can get it work by commenting out times in the profile.prf file. Loosing the mtime metadata in the process.

I see one can sudo unison and sudo with the --server-cmd on the other side, so that in effect unison gets executed as root, but the connection is still as normal user.

Is this the way to achieve bi-directional sync keeping the files modified time, preferably keeping user1?

0

Depending on the time frame needed for your sync, you might be able to get away with using two rsync processes. Setup a cron job to run rsync -au <source> <dest> on each host. That should keep both hosts "synchronized" within a certain time frame. You could also use inotify to run the rsync whenever a file changes.

  • A few files need to be merged as they were updated both sides. Does rsync --update replace the "older" with the newer one? If it was the case then I could run unison to take care of these few, after cron rsync did the main job. – tuk0z Sep 16 '15 at 21:39
  • 1
    Yes, that is correct. With the --update option, only files that are newer on the source will be copied to the destination. Files with the same timestamp and size on both the source and destination will be ignored. I believe there is another option that will force rsync to check the CRC as well. – smokes2345 Sep 19 '15 at 16:54
  • Then I'll dig in the checksum option. For newer is not a good criterium in case file was edited both sides. Yeap, and I realize my comment above makes little sense unless I knew in advance which files were updated both sides :} – tuk0z Sep 21 '15 at 20:57

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.