Unison is a free file sync utility that runs on Windows, OS X, or Linux. As with most of these things, Windows support is a bit of an afterthought, and can be tricky to work with. Here’s a step-by-step list of what I did to get it working. Note that I’m only setting things up for mirroring (ie one-way sync) so I only installed the SSH server and Unison text client on the “client” and the remainder of the stuff on the “server.” If you’re doing full 2-way sync, perform all the installations on both machines.
- Install GTK for Windows. I tried a couple of installers that didn’t work, but found an installer as part of this project that worked great.
- Install an SSH server. freeSSHd is a great little program, and it’s a tiny download. Make sure to install as a Windows service when it asks you.
- Configure the SSH server. Starting up the freeSSHd GUI actually tries to open another SSH server, even though you configured one to run as a service. This means that changes you make in the GUI won’t take effect until you restart the service. The only thing you’ll need to do is create a user, with password stored as SHA1 hash, that is allowed to use the shell.
- Configure environment variables. Unison expects to find an environment variable called
HOMEand will complain if it doesn’t find it. I set mine to
C:and it’s happy with that.
- Get a fake SSH client. Unison expects that it can say
sshand something will answer. So first download PuTTY and Plink and make sure they’re in your path. Then download the Unison-ssh wrapper and make sure it’s in your path. It will redirect any calls for
- Put the Unison client in place. Windows binaries are available here. Rename the binaries something simple like
unison. I suggest naming the text version
unisonas this is the name that Unison expects the client to have. Make sure the binaries are also in your path.
- Test your SSH. At this point you should be able to go to a command prompt and do this:
ssh -l username -pw password server "unison -version"
and get something like this:
unison version 2.27.57
- Test your Unison. Assuming that worked, try testing Unison with the
unison -testserver -sshargs "-l username -pw password" c: ssh://server//
which should give you something like this:
Connected [//server1/c:/ -> //server2/c:/]
- Set up your files. Congratulations, the servers are talking to each other! I suggest running the next step in the GUI, as there may be a lot of initial file syncing to be done:
unison-gui -sshargs "-l username -pw password" c:directory ssh://server//directory
It’s pretty self-explanatory, arrows point in the direction of updates, click “Go” when you’ve got it set up how you want it.
After the initial setup, you can continue using the GUI, or start using the text mode. There are a number of preferences that make things easier, which you can learn about in the documentation. As I mentioned, I’m using this for mirroring, so I use the
-force parameter to make sure the “server” always takes priority over the “client.”