Unison – file synchronization tool

Sponsored Link
Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.

Unison shares a number of features with tools such as configuration management packages (CVS, PRCS, Subversion, BitKeeper, etc.),distributed filesystems (Coda, etc.), uni-directional mirroring utilities (rsync, etc.), and other synchronizers (Intellisync,Reconcile, etc).

Unison Features

Unison runs on both Windows and many flavors of Unix (Solaris, Linux, OS X, etc.) systems. Moreover, Unison works across platforms,allowing you to synchronize a Windows laptop with a Unix server, for example.

Unlike simple mirroring or backup utilities, Unison can deal with updates to both replicas of a distributed directory structure.

Updates that do not conflict are propagated automatically. Conflicting updates are detected and displayed.

Unlike a distributed filesystem, Unison is a user-level program: there is no need to modify the kernel or to have superuser privileges on either host.

Unison works between any pair of machines connected to the internet, communicating over either a direct socket link or tunneling over an encrypted ssh connection. It is careful with network bandwidth, and runs well over slow links such as PPP connections. Transfers of small updates to large files are optimized using a compression protocol similar to rsync.

Unison is resilient to failure. It is careful to leave the replicas and its own private structures in a sensible state at all times,
even in case of abnormal termination or communication failures.

Unison has a clear and precise specification.

Unison is free; full source code is available under the GNU Public License.

Install Unison in Ubuntu

sudo aptitude install unison-gtk

This will complete the installation

Using Unison

If you want to open goto Applications--->Internet--->Unison

When you run it in GUI mode for the first time, you’ll be prompted to create a new synchronization profile. Simply specify the paths to the directories you want to keep in sync and you are done.

Enter First Directory

Enter Second Directory.As you can see, Unison supports synchronization via SSH, which is a handy feature for syncing remote machines.

Unison then checks both directories and displays all the files to be synchronized. Pressing the Go button performs the sync.

Although the basic operation of Unison is pretty straightforward, it offers a few advanced features, including a powerful and flexible conflict-resolution mechanism that provides a comprehensive set of options.

Once Unison has scanned the directories,you can specify the way it should handle conflicts with the options available under the Actions menu. For example,you can choose to solve conflicts in favor of the desired directory by choosing either the Resolve all conflicts in favor of first root orResolve all conflicts in favor of second root command. Also, you can force all changes from one directory to another and replace older files with newer ones.

Specifying all the synchronization settings manually each time you run Unison is hardly ideal. Fortunately, Unison provides an elegant solution – multiple profiles: For each profile, you can specify settings in a .prf file and save it in the ~/.unison directory.

Sponsored Link

Incoming search terms:

Related posts

32 thoughts on “Unison – file synchronization tool

  1. I’ve been looking for a utility to sync my documents between desktop and laptop, and this might be just the thing. Is it easy to schedule syncs via cron, or at startup? Also, can you setup filters for exclusions, or perhaps a cap on how much is transferred?

    [Reply]

  2. Note that Unison is not compatible across different (minor) versions. This can be a headache for synching between home and work.

    [Reply]

  3. Rsync is your friend. An advantage of rsync is bandwidth control, so that it doesn’t slurp up all available capacity. Rsync works well over SSH and can therefore be used over the internet.

    [Reply]

  4. If one site is the master, rsync is better IMO.

    However, if you want to keep your ~/bin coherent between 2 systems (work & home) where you’re editing/adding new files to either one, unison is better.

    It’s important both sides match versions. They won’t connect otherwise :-(. After you get past that hurdle, it is cross platform.

    [Reply]

  5. You can use unison even if you want a master copy, just force it to always replicate one way (using -force).

    rsync is great for ad-hoc stuff (no setup). unison keeps state information so it’s quicker, especially when working on large trees over slow links (it does not have to compare all the files via the link, it just sends changes and then resolves them).

    I used unison to keep my ‘downloads’ directory synchronized across 3 computers (2 desktops and a laptop shuffling between them). Never had a problem.

    Both can be tunneled through ssh.
    You could limit unison using trickle, though I’ve never done this myself.

    [Reply]

  6. I had some problems with swedish characters åäö when using Unison. During sync it created duplicate folders/files with junk-characters instead of åäö.

    But except this, it worked like a charm.

    [Reply]

  7. I’ve tried Unison multiple times.

    My biggest problems with it:

    The UI and configuration file format are pretty ugly.

    The other problem is that it’s written in OCaml, so it’s not very easy to hack on if you want to make changes.

    Other than that, I think it’s a great tool, just a bit rough around the edges.

    [Reply]

  8. @Scott@ I’ve been using unison for a while now and it’s awesome. (It’s awesome because I make changes on both computers and that would throw off rsync.) It’s dead simple to setup. unison syncs two folders. Exclusions are done via “-ignore ‘Path /path’ and -‘ignore ‘Name ‘. I dunno about file transfer limits though, although it might be possible.

    [Reply]

  9. I like Unison and use it from time to time. But my biggest issue is that files on a partition that I use to share data between Vista and Ubuntu always have different permissions. In particular, they look like executables when I list them in Ubuntu. Unison therefore offers to propagate changed even if the files are otherwise identical. In the Unison gui I see no option to ignore file permissions.

    [Reply]

  10. Do you know that Unison does not support Unicode (UTF8) ?

    If your file or directory name are Unicode with none English characters , you will see the problem.

    It has been described in the Unison web site.

    Use it with careful on your locale setting.

    [Reply]

  11. Watch out when using unison on windows, althou the latest releases have improved, it used to cause allot of bluescreens and 0 byte files.

    What also might be a problem using unison is when you sync your directory, and it’s large, that it hashes each file to see if there are changes. If it’s only 100mb or something then it’s fine, but don’t know what result it gives running it on a directory several GB large.

    For using it on windows and if you want a GUI I recommend making your own GUI(that does only what you need it to do). Saves you the trouble of making profiles etc.

    Hmm, after reading my post again it sounds a little negavive. Unison does the job pretty good, so by no means it’s a bad program. Just make sure you test it enough before using it on critical data ;)

    [Reply]

  12. @Crazy:

    Your suspicions of the hashing latency for large directories are justified.
    i tried to sync two 400Gb+ folders and it took Unison 25hrs+ to complete the initial comparison and that doesn’t factor in the time to do the actual trans/changes!!! and the folders were 95% similar to begin with!

    i was using it for a folder on Ubuntu client against folder on an ubuntu server over nfs.
    the same thing using Synctoy on windows client against folder on ubuntu server over samba takes 5-10m.

    i haven’t tried it again yet to see if it’s reduced and is just that long only for initial hash (too afraid).

    [Reply]

  13. It does take forever to hash large files. There are command line options like -fastcheck which look like they might help but they don’t appear to. I’m looking for a good way of syncing two directories with v large files in. All I want is filename and modified dates comparing. Any ideas?

    [Reply]

  14. Hi,

    After sync, the copied file has the current date & time, is there any way or any other application can maintained the copied/synced file original modified date & time ?

    thanks

    [Reply]

  15. I have played with unison but to me you are sacrificing a lot to have a gui interface. Rsync is your friend. I find it does the job faster, better and with less issues. The issue with unison about not working with differing builds drives me bats. I want a sync tool that is robust and just works. I don’t want to have to waste time trying to interpret why it might have failed. It is hard enough for me to have the discipline to do an actual sync.

    [Reply]

  16. I am simply stuck with
    Received unexpected header from the server:
    expected "Unison 2.27\n" but received "Unison 2.13\n00000000",
    which differs at "Unison 2.1".

    Server is ubuntu hardy 64
    Linux ice 2.6.24-19-server #1 SMP Wed Aug 20 18:43:06 UTC 2008 x86_64 GNU/Linux
    and client is hardy 32
    Linux can 2.6.24-21-generic #1 SMP Mon Aug 25 17:32:09 UTC 2008 i686 GNU/Linux

    How can I proceed to get these two synced?

    [Reply]

  17. 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

    C:

    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!

    [Reply]

  18. Unison doesn’t see my USB drive so I can’t sync any files there. Conduit is fine but gets an error 20% in to the synchronize, so I’m trying Unison as an alternative

    [Reply]

  19. Long time rsync user here, primarily on Solaris. Can someone give me compelling reasons why I would discontinue using rsync for Unison?

    rsync -avP source:/dir target:/dir

    seems simple enough to me.

    [Reply]

  20. @Svrocket as far as I can tell, there is no disadvantage to sticking with rsync, _as long as you only update one directory_. If you update both, like the example given above of adding new scripts to your bin directory on various hosts, unison allows this bidirectional capability.

    I have not done any head-to-head performance testing, but I would be interested to see how rsync and unison compare on big directory structures with small changes, which is my most common use case.

    Andy

    [Reply]

  21. Problem with perms?
    To the file /home/.unison/[i]profile_name[/i] add string “[b]perms = 0[/i]“.
    Enjoy! :)

    [Reply]

  22. For my bin directory, svn works great.

    For my media (synced between work and home) unison is too slow. The hashing takes a full second per ~5m file; I’ve let it sit for days without completing the initial index. My wild unfounded accusation is that fastcheck doesn’t apply for the initial index, which is a shame since existence/mtime/date is plenty to differentiate the changesets I’m dealing with.

    rsync on the other hand works insanely fast but doing:

    rsync -auP a/ b/
    rsync -auP b/ a/

    while propagating additions well has the unfortunate side effect of resurrecting files deleted in either place.

    [Reply]

  23. I prefer using my customized shell scripts with
    rsync, scheduled timing, syncronize on logout, logs, report, and other neat stuff.

    Insanely fast and fully automated.

    Unison is uber slow and not totally reliable IMHO

    Lol, the ubuntu screenshots watermarked are really sooo lame. screenshots from an open Source Operating system. lol, this cannot be un-seen.

    [Reply]

  24. Hey I’m not trying to steal any thunder from Unison, if there is a significantly easier/better sync tool over ssh I’m all ears.

    There is a mode to rsync, it takes 2 command lines where to update target to source and update source to target with a certain syntax and supposedly you get Unison-like behavior, Unforuntely I’ve never had the need to do *2-way* syncronization, I’m a “one-way replication” kind of guy where I make my shell scripts push new files from source to target, LEAVING the files on the target (do not delete).

    Mostly I use Solaris and Opensolaris, which co-bundles or pre-installs rsync ver 2.6.9 so I’ve gotten real used to rsync. Also, I have to jump thru too many hurdles to add software that’s not pre-installed (lame feature of my workplace) so rsync wins by path of least resistance. But someday I’ll try Unison. And Dirvish. And ???

    [Reply]

  25. I’d like to keep a synchronized folder on primarily my laptop (Windows XP), and my main desktop (Kubuntu Hardy heron – I like Hardy) and also (but less important), a desktop at work (with Win XP on it).

    The main reason is to keep a synchronized version of a keepass db file (keepass is a great little app for storing passwords) but will be great to have it work for any files.

    Keeping track of working copies thru SVN would be a great feature (I recently signed up for a VPS running kubuntu 8.10, to serve as a central svn repository).

    If anyone has advice on what application (freeware preferably) that runs on Windows + Linux to achieve this, would be great to hear about it!

    just curious if Unison would work for more than 2 machines and also if it is suitable for a central svn-repository setup?

    Many thanks for help,
    gvanto

    [Reply]

  26. The description is lacking.

    I’ve got a 50gig file in 2 places, one of them has had a few megs of mods made to it.

    Is this program going to transfer a few megs, or 50 gigs, to bring the older file up-to-date?

    [Reply]

  27. Chris: The description isn’t lacking, you just have to read all of it.

    “Transfers of small updates to large files are optimized using a compression protocol similar to rsync.”

    So, just like rsync, a few megs.

    [Reply]

  28. Do not use this tool – I may sound like a whiner – but I just lost 21Gb of data during it “syncing” a folder. It brought all the subfolders down off my remote drive bar one, which it decided to sync up to the remote drive, by removing all the files on the remote drive under that folder as they didn’t exist locally.

    Thanks.

    [Reply]

Leave a comment

Your email address will not be published. Required fields are marked *