Unison – Secure synchronization of 2 computers

When not writing on my blog I am doing my master thesis in physics at the Niels Bohr Institute in Copenhagen. At the university I use my subnotebook and at home I have a more powerful desktop with a bigger screen. I would like to have the file systems synchronized both considering the convenience and the security of not having the data on one disk only.

There are many ways to do synchronization including home brewed rsync scripts, CVS, SVN and more, but I wanted something that was easy to setup, so I chose Unison. One of the great things about Unison is that it is very easy to use and supports SSH – the latter makes the synchronization secure even over the dangerous internet (unlike FTP). Furthermore Unison supports both Windows, OS X and Linux and even supports syncing a Linux folder with a Windows folder. The setup much more easy than using CVS and SVN which makes unison the right choice for most users. CVS and SVN also need to be notified when new files are added to the project but this is not necessary with Unison.

The installation was surprisingly easy. I needed the unison program running on my desktop and a running openssh-server process which I already had, so the setup amounted to:

root@nobel:~# aptitude install unison

On my laptop I need the unison program and the nice GUI:

root@dirac:~# aptitude install unison unison-gtk

That was it 🙂

The configuration of the laptop was the next step. I started the Unison GUI and created a new profile. Next I needed to choose the folder to sync on the locale machine:

Second I needed to choose the folder on the distant machine as well as the server name

Finally Unison started to look for changes and listed them in the GUI:

Beside SSH support Unison can also sync local two local folders which can be nice in a NFS or SSHFS setup. All in all I think Unison is the easiest tool to solve my problem and the great support for other OS’s might come in handy later.

This entry was posted in Articles, Computer. Bookmark the permalink.

6 Responses to Unison – Secure synchronization of 2 computers

  1. TDJ says:

    Tried it, liked the idea. But it failed (at least on Windows) because it could not handle long file names and accented characters (ex: á ø å æ â ) properly.

    How is that under Linux ? Did you test file names with spaces and accents ?

  2. TDJ: Can’t say that I have. I got tired of problems like quite a while a go, so now my files are always name “Foo-bar-ae-oe-aa.txt”. I know this is not a solution to the problem but merely a hack.

    I guess the right way to look at this is to see if the encoding on the server is the same as on the Windows machine. I think most Danish Windows installations use “ISO 8859-15” whereas most modern Linux installations use UTF8. By changing the character set on the Linux machine this could perhaps be solved. But then again all the files on the Linux machine has to be changed to 8859-15 with a tool like iconv and this is annoying as well. 🙂

  3. M@rtin says:

    Hi TDJ,

    I’m also using Unison to sync the many GB of data for my thesis between several computers, one of them with Windows XP, another one running MacOS X.
    In the beginning I nearly got mad… I had the same problem you are describing (special characters in German like ä ö ü ß µ in path names made the sync fail).
    The problem is that not only the transfer of this one file but the whole sync fails.

    After fiddling with character encodings without success, I also used the hack Thomas proposes (only pure ASCII characters in filenames) and now it works perfectly and helps me a lot keeping my data consistent and working on different machines on the same data.
    There are tools to replace characters in filenames automatically which can help you doing that…

    It is not a really good solution, but if you ARE using different operating systems, the only way to avoid such problems is avoiding unicode characters in filenames.

    If you absolutely can’t give up your filenames, join the discussion in the unison users group http://tech.groups.yahoo.com/group/unison-users/ (search for character encoding) – we have even offered a reward for the one fixing this problem but up to now I fear it is not beeing solved.

    Kind regards


  4. Jan Lindh says:

    Regarding unison and special characters like åäö:

    Well this is slightly outside of ubuntu, but about half a year ago I set up my wifes windows PC to sync against my debian etch server. Using a minimum of cygwin with unison was the solution. Fixing so unison handled filenames with swedish characters wasn’t easy, but at last I found a way.

    …problem is – I can’t remember how I did it!

    The only thing that rings my mind is that this was a cygwin problem. And the fix could have been changing the Cygwin.bat file to:

    —————–Cygwin.bat beginning————-
    @echo off


    chdir C:\cygwin\bin

    set CYGWIN=tty

    bash –login -i

    —————–Cygwin.bat end————-

    How the original looked like I can’t remember.

    Not much of an answer, but at least something…

    Good Luck!

  5. zcat says:

    Unison has always been slow and naggy for me..I tried it a couple of times cause I wanted to do three way syncs. Never featured well..takes ages to get the initail file lists (even after the first time) and then hangs! But RSYNC is way sleeker, stable and solid…and there is a nice GUI (grsync) that also helps teach you the unix commands. Always fast and secure if used through ssh

  6. m.sandino says:

    Well, this may be a little late, but anyway:

    Since version 2.40 Unison provides a “unicode” preference. With that set to true I am able to sync files between my Linux- and my Windows-machine without any troubles regarding german special chars (ä,ö,ü,ß).

Leave a Reply