System Administration

Essential System Tools: Unison – Excellent Console and Graphical File Synchronization Software

Last Updated on June 23, 2023

This is the latest in our series of articles highlighting essential system tools. These are small, indispensable utilities, useful for system administrators as well as regular users of Linux based systems. The series examines both graphical and text based open source utilities. For details of all tools in this series, please check the table at the summary page of this article.

For this article, we’ll look at Unison, a cross-platform file-synchronization tool. There’s both a terminal-based interface, and a graphical interface using GTK+.

The software offers 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 made up to date by propagating the changes in each replica to the other.

Unison is capable of recognizing updates in both replicas and deciding which way they should be propagated. Unison is different to rsync, which is a mirroring tool. Both Unison and rsync use the so-called “rsync algorithm”, a type of delta encoding, for performing updates.

The initial release of Unison was written in a research language called Pict, a statically typed programming language, in 1995. Benjamin Pierce, Trevor Jim and Jerome Vouillon started working on the present codebase in Objective Caml in 1998.

Installation

The project has a GitHub page where you can clone the project’s repository, and compile the source code. You’ll need the Objective Caml compiler. Wielding your trusty shell, you can fire off the commands below. If you don’t have lablgtk2 OCaml library installed, the commands will only build the terminal-based tool. But assuming the library is installed, the commands will also build a unison executable with a GTK+ graphical library.

$ git clone https://github.com/bcpierce00/unison.git
$ cd unison
$ make
$ sudo make install

If you don’t fancy dipping your toe into the world of compiling, you can install Unison with the relevant package for your distribution. It’s a popular tool, so you should find it available from your preferred package manager.

The project also provides binaries for Linux, Mac OS, and Windows. Contributors have provided binaries for FreeBSD, OpenBSD, Cygwin, GODI, ARM Linux, and even the Sharp Zaurus.

Connection setup

You’ll need to set up a profile where you specify the two directories to synchronize. A profile is a text file that specifies permanent settings for roots, paths, ignore patterns, and other preferences, so that they do not need to be typed at the command line every time Unison is run.

Unison offers a Profile Creation Assistant wizard to simplify the creation of a profile. You define a profile name with a description. Then you choose the type of synchronization. The following types are available:

  • Local synchronization where Unison synchronizes a local directory with another local directory.
  • Using SSH – this is the recommended way to synchronize with a remote machine. The local machine needs a SSH client installed, and the remote machine needs an SSH server installed. There’s the option to enable compression, which boosts performance on slow net connections.
  • Using RSH – an alternative way to synchronize with a remote machine. The local machine must have an RSH client, the remote machine needs an RSH server installed.
  • Through a plain TCP connection.

Here’s an image of the profile wizard helping us to set up a connection using SSH.

Unison-Connection-Setup

Next page: Page 2 – In Operation

Pages in this article:
Page 1 – Introduction / Installation
Page 2 – In Operation
Page 3 – Other Features
Page 4 – Summary

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments