1

I'm effectively asking this question: Unison: sync only in one direction but I'd like to apply the accepted answer to a profile script. Can I do that?

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

Cheers!

bitrat
  • 25
  • 9
  • 1
    I'm going to ask the obvious question here: why not use rsync simply? Also, what do you mean with "profile script"? – Edward Feb 02 '22 at 21:26
  • Yeah you can. Just look in the [Unison manual](https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#profile) and instead of using the command-line options `-force` and `-nodeletion` use the corresponding commands in your profile. – Mike Pierce Feb 03 '22 at 21:38
  • I can't speak for the OP, but in my case, the reason not to use rsync is that the source is a Windows machine, and running rsync on Windows is more trouble than Unison. – Enno Mar 31 '23 at 09:38

1 Answers1

2

Yes, of course you can write that command line to the profile script.

  1. Locate the corresponding .prf unison preferences/profile file (usually under $HOME/.unison, but please double check, this may vary depending on your OS or Unison installation)
  2. Edit the .prf file and add the following:
    # Unison preferences
    label = Sync in only one direction (mirror)
    root = /src/dir
    root = /dest/dir
    force = /src/dir        # force changes from this replica to the other
    nodeletion = /dest/dir  # prevent file deletions on this replica
    noupdate = /src/dir     # prevent file updates on this replica

You can also replace step #1 above by creating a new preferences profile using the Profile Editor in the GUI, or your text editor of choice. Please remember the name and location of this file (e.g. $HOME/.unison/sync-one-direction.prf). Then you can call unison from the command line like this:

unison $HOME/.unison/sync-one-direction.prf

or

unison -i 

The latter will start an interactive profile selection.

HTH

fernan
  • 36
  • 6