Unison — the file synchronizer

I’ve been looking for a good way to syncronize files between my work machine (Windows) and my home machine (Linux). I’ve even tried writing my own scripts to do it, but nothing seemed to be right. I’ve always thought, “There has to be something out there.”

I stumbled onto Unison almost by accident. I won’t say that it’s easy to setup (I think that it needs a Quick Start Guide for starters) but it works well. I’ve been using it for a few weeks and, since I got it working, I have no complaints.

My initial hiccup was the the version on my Linux machine and the one that that I found on Windows were a different version, with the Windows one being older. Since I don’t have a compiler on my Windows system outside of Cygwin, I grabbed the Cygwin version — same issue. So I grabbed the source of the Linux version and compiled it on Cygwin — now we were ready to go.

Before you can do anything with Unison, you have to have a config file for each configuration. It’s actually pretty easy. Here is an example from my Windows ~/.unison directory:


## this is the directory on my Windows machine
root=/cygdrive/c/DOCUME~1/HOSTET~1/Projects/personal/plc
## this is on my linux machine  Note that it does this via SSH.
root=ssh://foo.bar.com//home/mikeh/Documents/

## directories that I want to sync.  
path=deacon
path=psc

## I don't want to log messages.  
## You will probably want this to be true
## the first few times you run it.
log=false
## files to ignore (can be written by unison).
ignore = Path {deacon/feb2005/Feb, 2005.xls}

I saved this file as ~/.unison/plc and, when was ready to sync the files, I just typed unison plc at my Cygwin prompt.

When you start Unison, it will ask you which direction should it go — sync from local to remote, or vice versa. When I first ran it on my work machine, the directory there was empty — I wanted to move a ton of files from my home machine to my work machine. So a wrong move could have removed a ton of my files!

If you have a need to sync files across a network and have ssh access from one machine to another, I’d highly recommend Unison.

Leave a Reply

You must be logged in to post a comment.