Blog
Jan 05, 2009

Unison on Windows


General
Posted: Jan 17, 2007
I've been using Unison to synchronize my Linux laptops for quite a while.  It works great since I have two laptops that I use interchangeably.  However, on one of the laptops I still have a Windows partition for a client that is using Windows servers.  The VPN software and testing of the code just works better that way.  But when I'm using Windows I don't have access to any of my documents.  They're all on the Linux partitions.

Most references for getting Unison to work on Windows require running cygwin (which is a minor pain) or generating keys with openssh.  I really didn't want to go through that hassle.  All of the machines are local to my network and I just don't need the higher level of security that the openssh keys would give. Here's a quick tutorial to get Unison working on Windows.

Step 1)  Download Unison for Windows.  I'm using version 2.13.16 because that's the version I'm using on Linux.  Make sure the versions are consistent across all of your platforms.

Step 2)  Run Unison once to set up the profile.  Put in the directories you want to synchronize.
Root 1: C:\Documents and Settings\timb\My Documents
Root 2: ssh://192.168.0.254//home/timb/LaptopBackup

When you try to connect you may get the message "Uncaught exception Unix.Unix_error(20, "create_process", "ssh")".  A more common error if you've tried to use plink as the ssh utility is "Fatal Error" "Lost connection with the server".  Plink.exe doesn't support all of the commands that the full ssh supports. 

Step 3) In order to overcome the different command line options between plink.exe and ssh we will need to create a custom batch file to execute plink

@plink %1 %2 %3 -pw yourpassword -ssh  "unison -server -contactquietly"

The @ at the beginning of the line is important.  @echo off is not sufficient for this script.  Save this script somewhere in your path.  I called mine plink-cmd.bat and put it in c:\Windows.

Step 4) Modify the .prf file to use the custom command we just created.  Go to c:\Documents and Settings\yourusername\.unison  There is a file called default.prf (or something else if you named your profile something.  Edit that file and add the following:

sshcmd=plink-cmd.bat


Step 5) Rerun Unison and it should work.  Happy synchronizing!
Print
All content copyright 2006 The Bornholtz Group  •  Bornholtz.com blog