Unison: sync only in one direction

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.


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).