I’ve read probably fifty articles about Unison on Linux and Windows and how to make them sync properly. However, none of them pertain to my needs. They all involve handling the syncing on the Windows side, or involve setting up an sshd using cygwin, or any number of other crazy and overly complex solutions. I’ve found another way, and it’s a hell of a lot simpler than any other I’ve seen to date.
Dependencies: Unison, and a working knowledge of the Windows and Linux command lines.
First, use your package manager to install a version of Unison on Linux. I’m using version 2.32.52. This matters. Unison is very persnickety about corresponding version numbers. In Ubuntu, the older 2.32.52 version remains in the repositories and can be installed by
sudo apt-get install unison2.32.52. If you just install the
unison package it will be a newer version and I don’t believe there’s a corresponding Windows release. Next, install version 2.32.52 downloaded from the Unison website on the Windows host. You do not need GTK+ or cygwin or any other dependency.
Now, to set up. You’ll find, on the Windows machine, GTK and text versions of Unison. Delete the GTK one. Create a shortcut for the text one on the desktop or something. Edit the shortcut’s properties. You’ll need to add
-socket 48000 or some other port to the end of the command. If everything goes right, double clicking on your new shortcut should open a terminal like window that just says, “server started.” Yay. Leave that there.
On the Linux side it’s a little more complicated. I wrote a shell script to do this for me, but that’s not necessary. Let’s look at the command I use to invoke Unison and run through a directory:
unison socket://windowsip:48000//Users/YourWindowsUsername/Documents /home/yourlinuxusername/Documents
The thing is, Windows handles spaces in paths well, and Linux doesn’t, so spaces have to be escaped properly. Here’s an example taken directly from my script:
unison socket://10.0.1.5:48000//Users/Dan\ Hadley/Documents /home/tralce/Documents
See that backslash? Yeah, put one of those right before a space in any path or filename. But you knew that. Anyway, adjust that command to your needs and you should be in business. A couple points:
» I always use the
-perms 0 option on the command in Linux. It’ll get rid of the annoying “properties have changed” thing when syncing.
» Try adding
-fastcheck true if things run too slowly.
-batch if you want it to run through the sync without prompting you about changes.