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

13

1

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

MountainX

Posted 2012-04-21T22:17:47.897

Reputation: 1 735

Answers

5

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

MountainX

Posted 2012-04-21T22:17:47.897

Reputation: 1 735

6This could be improved by re-working so the question reads like a question and likewise for the answer. – suspectus – 2015-03-25T19:04:59.487

hahahahaha this question is hilarious. Does this work as parameters to the GUI profiles, since they're basically just command line sets? – bright-star – 2014-02-03T06:12:57.110

1

You can use it like that root is root directory and the can define the all paths what you want..

# Roots of the synchronization
root = /
root = ssh://x.x.x.X//

# Paths to synchronize
path = /etc/httpd
path = /var/www

Akshay Kumar

Posted 2012-04-21T22:17:47.897

Reputation: 11

1

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

jhat

Posted 2012-04-21T22:17:47.897

Reputation: 11