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?

1 Answer 1

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.

3
  • 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
    Commented Sep 16, 2015 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
    Commented Sep 19, 2015 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
    Commented Sep 21, 2015 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .