4

I am using Unison to synchronize some files between my home computer and my work computer. However, the two computers cannot connect to each other directly via ssh so I synchronize via an USB thumb drive (formatted with ext4 to keep permissions).

The problem I have is that Unison stores the synchronization profile configuration locally (in the .unison directory) instead of in the folder itself. This means that some information, such as ignored files, needs to be duplicated in the two profiles I keep.

It there a way to keep the synchronization profile automatically in sync between the two computers?

2 Answers 2

1

I keep the profile inside the directory to be synchronized. Inside ~/.unison, I put a symlink to the real profile. This has worked well for me. It also allows me to quickly 'bootstrap' a new machine: simply copy the profile from the USB drive to a new computer, and start anew.

There is one 'gotcha'. If you add an ignore line to the profile (on one computer) which matches a file that happens to exist on the USB drive already, that file will be transferred from the USB drive to the other computer at the next Unison synchronization, in spite of the ignore line. The reason is that the profile is scheduled to be transferred, but is not effective (on the other computer) until the next synchronization. Other than that, I have not yet encountered any problems.

1
  • Works perfectly :) It never occurred to me that putting symlinks inside .unison would work!
    – hugomg
    Commented Sep 30, 2015 at 1:16
1

The alternative I ended up with is to do a two-step synchronization. I have an unison profile for synchronizing my unison profile(s)

#.unison/sneakernet-init.prof

label = Unison profiles

root = /home/hugo/.unison
root = /media/hugo/MYDRIVE/Sync/Unison

path = sneakernet-common        # ignore rules, diff command, etc
path = sneakernet-dotfiles.prf  # profile for my dotfiles
path = sneakernet-hugobox.prf   # profile for my other stuff

Then, I use a script to run unison with each profile in turn

#syncronize-things.sh
unison-gtk sneakernet-init
unison-gtk sneakernet-dotfiles
unison-gtk sneakernet-hugobox
sync # Flush file system caches

This solution is a bit cumbersome because I need to run unison 3 times instead of once but it has the advantage that none of the unison profiles are responsible for synchronizing themselves (which leads to the strange behaviour where you may need to run unison twice with the same profile to get things to work)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .