How to use unison's path option with multiple paths?

I want to sync the following locations using unison:

  • /home/user/Audiobooks with /shared/Audiobooks
  • /home/user/Music with /shared/Music
  • /home/user/Podcasts with /shared/Podcasts

What would the unison command line parameters be? Based on this, I can guess

If one or more path preferences are given, then Unison will synchronize only these paths and their children. (This is useful for doing a fast sync of just one directory, for example.) Note that path preferences are intepreted literally—they are not regular expressions.

Here's my guess. Is that correct?

unison -ui text /home/user /nocrypt/Shared -path Audiobooks -path Music -path Podcasts 

I could also use a profile. I read the help docs and found the an example that I adapted. I'm not sure it is correct, however.

Modified from the help docs: Here is a more sophisticated profile, illustrating some other useful features.

# Roots of the synchronization
root = /home/user
root = /shared

# Paths to synchronize 
path = Audiobooks
path = Music
path = Podcasts

Is that correct?

By the time I finished writing this question, I pretty much have it figured out. I think both methods above are correct. The great thing about unison is that you can do a "dry run" the same way you would do an actual sync. The default action is always "no action" (after all changes are presented). I'm going to test it now and see if it works. I guess I don't need an answer, but I'll leave this question here for reference (and answer it myself with a confirmation of whether or not this worked).


Solution 1:

Yes, I am confirming what I stated in the question is correct.

Solution 2:

Like your question, I'm posting this for reference.

You can mix and match variables. If you want to use shell variables, for example, you start with a profile as per usual, but pass the arguments that contain shell variables while invoking the command - the reason being that you cannot use those variables normally from within a profile file.

root = $HOME seems to work, but in root = ssh://host//$HOME, $HOMEis not recognised as a variable.

Example documents.prf:

# select folders
  path = Documents
  path = Desktop
# options
  batch = true

The command you could then use would look something like this:

unison documents -root $HOME -root ssh://user@remotehost//home/$USER