Unison is an application which allows files to be synchronised between local or remote directories. I find it incredibly useful for keeping my documents etc synchronised between my various computers. I use it for many things, including my ~70GB music collection so I can verify that it can handle large(ish) amounts of data.
Unison is cross platform (Windows, Mac, Linux) which is nice bonus, if not actually that useful for me at the moment since I run all Linux.
By way of example, I’ll explain how I sync my music collection between my desktop and laptop. The exactly instructions are based on Ubuntu, but the overall process is much the same whatever you’re running.
To start with I need unison installed on both computers. The package is simply called “unison”, so installed how you prefer (sudo apt-get install unison).
To configure which files/directories to work with unison uses “profiles” defined in simple configuration files which live in ~/.unison.
In a file called music.prf on my laptop (where I will be running the sync from) I have the following:
root = /home/chris/Desktop/Media/Music root = ssh://192.168.1.4//home/chris/Desktop/Media/Music
The first line defines the local directory, and the second one the remote one (“192.168.1.4″ is the IP address of my desktop). I’m using the SSH protocol to transfer data, with the appropriate keys on each machine to allow access with providing a password.
Then I just open the unison GUI (Applications -> Accessories -> Unison) and select the music profile when prompted. At this point unison will contact the remote machine and start looking for changes.
The first time a profile is used you will get a warning about missing reference data. This is normal the first time and can be safely dismissed.
For my music collection of around 75GB across 15,000 files the initial scan takes some time, as hashes must be calculated for everything. Subsequent scans are much faster.
When it’s done scanning the files unison displays a list of changes for review before continuing. Any conflicts can be addressed by manually setting to overwrite from either root, or to ignore the files for this session.
The “Go” button starts the actual file transfers, with individual status displayed for each file. Once the file transfers are all complete, everything’s done. Simple!
Although I don’t myself since I want to handle conflicts manually, using unison from the command line this could easily become a cron job have things synchronised automatically.
References:
Comments (3)
I’m curious as to why this is better than the time-tested traditional rsync. The fact that the 600lb gorilla isn’t mentioned makes me question the advice.
The fact that rsync isn’t mentioned doesn’t make the advice any less valid. Maybe a comparison is a topic for another post though?
@Evan – The main advantage is that unison allows bidirectional transfers (two way) where rsync is more often used for unidirectional transfers (one way).
In the example I describe above, I make changes to my music collection in both places, so it’s nice to easily be able to merge these together.
In my mind rsync and unison are different (if similar) tools – I use both!
There is more discussion of this on the reddit thread, although these are not my own words.