How Unison Changed My Life and Made Me a Better Remote Worker

A while ago, I shared some bash scripts that I’d written to sync my local MacOS machine to my FreeBSD dev environment. Earlier, I’d written about mounting a NFS share on a Mac.

I will be using pushchanges and pushall no more! I found Unison, and my troubles are lifted. Unison is a great little app that hooks up a local folder with a remote folder via SSH. Since it runs on both machines as a user-level application, there’s no need for changing kernels and no lag from trying to scan a remote filesystem. However, you get the same effect that you’d have from an NFS or SSHFS mount. Changes take about a second to propagate between the two systems, but that’s pretty forgivable, since it happens in the background and only uses the network bandwidth that it actually needs to.

I did run into a few caveats with it:

  1. You have to install it on both machines, and it has to be the same version on both machines. Since my yahoo BSD machine could only find version 1.16, that was what I had to install on the mac.
  2. Read the command-line options, and use them. The UI is pretty nice, but without the -repeat option, it’s pretty much useless.
  3. Older versions are a bit flaky, especially when it comes to symbolic links. Make sure that you carefully set the -ignore flags to avoid any symlinks in your sync folders. (Frequent use of gmake-symlink is a big culprit.)
  4. If it dies on an error, it might corrupt the archive. Delete the archive on both machines, and try again. (Archive files are in ~/.unison/ and start with “ar”.)
  5. The mac puts its unison stuff in ~/Library/Application Support/Unison/. Do ln -s "~/Library/Application Support/Unison" ~/.unison and you’ll save yourself a lot of remembering.
  6. Sometimes, it’ll hit some file that makes it barf. I don’t know why. In my case, it was “Rate.php”. I just deleted the offending folders on both machines, and it ran fine. Then, while it was running in -repeat mode, I checked out the folders, on one machine and it synced them without any hiccups. Don’t know why, but it works.
  7. Changing the .prf file in ~/.unison/ and running from the command line is a lot faster than loading up the GUI each time and changing the text fields.

The error message that I saw most often was Uncaught exception Invalid_argument("String.sub"). Once that showed up, I’d get disconnected from the server, and had to delete the archive and try again. The -debug option is handy for figuring out what’s going on.

I’m still mounting my home folder from my BSD box onto my mac. But I curse at my slow-as-dirt VPN connection a lot less now that I’m editing code files locally and only transferring the changes without any effort on my part.

Leave a Reply

Comments are moderated like crazy using a variety of plugins. There is a very high likelihood that your comment won't show up right away, especially if you have never commented here before, but it was not deleted.

Please be patient, and do not post your comment more than once. It will show up once it is approved.

You must be logged in to post a comment.