Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unison: sync only in one direction

If I have folder A and B, is it possible to sync the new files from A to B and to not erase in B files erased in A?

That is to say, I would like to use B as a big container for any file, including the one that I once synchronized from A and than erased. I think is considered kind of "one way syncing".

like image 947
Chamaeleon Avatar asked Aug 23 '17 19:08

Chamaeleon


2 Answers

I understand that you are having these two requirements on Unison

  • mirroring folder A to B and
  • preserving data on B

Mirroring

According to the Unison manual, the -force xxx option "effectively changes Unison from a synchronizer into a mirroring utility". The force option takes the folder that is to be favored as argument. Unison will resolve all changes in favor of this folder.

The commandline to mirror, e.g., folder /src/dir to /dest/dir would be

unison /src/dir /dest/dir -force /src/dir

Preserving

Use the option -nodeletion xxx to prevent Unison from recommending any deletion on the folder xxx as default action.

The commandline to preserve files on /dest/dir after they have been deleted from /src/dir would be

unison /src/dir /dest/dir -nodeletion /dest/dir

Sum up

So in total you want to run Unison with these two options to satisfy your requirements:

unison /src/dir /dest/dir -force /src/dir -nodeletion /dest/dir

Notes

Until you have set up Unison to run in batch mode, I recommend to run Unison in interactive mode using the graphical UI. Working with the graphical UI is more convenient as you see all pending changes including the default actions Unison suggests.

When you are satisfied with the default actions, you can run unison in batch mode (option -batch) using the textual UI. In batch mode, changes with default actions will accepted, changes without default action (due to conflicts) will be skipped.

Remember, these options can be overridden in interactive mode by the user. They are in no way an absolute protection against deletion, they just provide guidance to Unison about how to decide on the default action. In interactive mode, the user can always override the default action, i.e., press "<" to propagate the change to the source folder (the direction which you do not want).

like image 83
Daniel K. Avatar answered Nov 09 '22 14:11

Daniel K.


Yes, you probably want to use noupdate and/or nodeletion options: -nodeletion xxx prevent file deletions on one replica -noupdate xxx prevent file updates and deletions on one replica

Read the full description in the manual.

like image 25
jimis Avatar answered Nov 09 '22 12:11

jimis