Synchronizing hosts with Unison


Unison is an open-source alternative to Rsync.

Although Unison uses the local host's clock to check whether a file has been modified, and hence, is not affected if the local and remote hosts' clocks are not in sync, you might want to ensure that they are. See Synchronizing hosts through NTP for more infos. This also includes taking account the time zone parameter if the two hosts are not located in the same area.

Linux Setup

Using Unison

Installing OpenSSH

Windows Setup

Using Unison

Clear-text connection

For this mode, SSH is not needed. The remote host must be running Unison as a process with unison -socket NNNN, where NNNN is any available port number. An important difference with SSH, is that in this mode, paths specified by the client host are interpreted relative to the directory where the Unison server is started on the remote host instead of the user's home directory.

Synchronize a local directory with unison a.tmp socket://remotehostname:NNNN/a.tmp

Secure connection with SSH

We'll first check that Unison works when trying to sync two directories located on a single host.
  1. Cd to the directory where Unison is located, and create two sub-directories a.tmp and b.tmp
  2. Create test files in both directories
  3. Open a DOS box, and run unison a.tmp b.tmp. Make sure that files located in ./a.tmp are copied into ./b.tmp, and vice-versa
  4. Make changes to any of the files, and run unison a.tmp b.tmp again. Check that changes are replicated.
Next, let's check that both SSH and Unison are running on the remote host by running ssh remotehostname unison -version . If that works, cd to your home directory, and synchronize the local a.tmp sub-directory to you home directory on the remote host: unison a.tmp ssh://remotehostname/a.tmp . If the user account that you use to log on to the local host is different from the one on the remote host whose home directory contains the target directory, run unison a.tmp ssh://username@remotehostname/a.tmp .

Installing SSH


Cygwin's port of openssh Add an SSHDIR environment variable that points to where SSH.EXE is located, and add it to the PATH variable. Create a HOME variable that points to your (guess what) home directory on the local host. This directory will contain a .ssh sub-directory to host SSH's configuration files.

Open a DOS box, and type the following to check that your SSH client can connect to the remote SSH server: ssh -l .

If you use CygWin, add the following to your .bashrc file: export PATH=$PATH:SSHDIR (If .ssh is located on the C:\ partition, SSHDIR = /cygdrive/c/ssh).

If you are logged in with a different user name on the local and remote hosts, provide your remote user name when providing the remote root (i.e., //username@host/path...).

Building Unison from scratch

Note: For best performances, build Unison with the NATIVE=true switch to take advantage of the native-code OCaml compiler. For maximum portability, use make STATIC=true. For debugging purposes, run make DEBUGGING=true .


  1. Grab the Objective Caml compiler release 3.00 or later
  2. Build either the native-code compiler (recommended) or the bytecocde compiler: make world opt, su to root, make install
  3. Cd to the directory where you untarred Unison, and run make UISTYLE=text
  4. Run ./unison to check that it works


  1. Get a copy of MS Visual C++ release 6.0 or later
  2. Get the Windows version of the Objective Caml compiler
  3. Cd to the directory where you unzipped the Unison source code, and run make UISTYLE=text to compile the executable.

Upgrading Unison

All replicas should be synchronized before moving to a newer release of Unison, to protect against changes in archive formats.


First, try to run Unison in debug mode (-debug all). If the error is not obvious, check the version of Unison you are running (unison -version), check the archives of the mailing list . If all else fails, end mail to