Synchronize Files with Unison
Posted on , Updated on , by Linode .
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Unison is a file synchronization tool that allows users to maintain two instances of a given file set on two systems up to date and identical. The tool is designed for maximum usability in a variety of contexts and uses protocols like SSH to securely transfer data between folders. Furthermore, the system is designed to be fault tolerant in the case of interruptions and modifications to both “source” and “remote,” and aims to always leave both instances of a file or directory tree in a known working state. Unison can be deployed to synchronize files between systems running disparate operating systems, to backup systems, or as part of a content deployment system, among a plethora of other use cases.
Before beginning this guide, we assume you have completed the getting started guide. If you’re new to Linux system administration, we recommend considering the introducing Linux concepts guide and the administration basics guide. If you’re simply looking to gain access to your Linode on your local system, you may want to consider deploying a remote file system. Conversely, if you need a more complex backup system, your needs may be better served by an incremental backup system.
Install Unison on a Linode
CautionUnison is no longer maintained under active development.
Debian 5 (Lenny)
Begin by installing the required software for Unison on the remote machine. Issue the following sequence of commands to ensure that your system’s package database is up to date, that all installed packages are up to date, and install Unison:
apt-get update apt-get upgrade apt-get install unison
Debian also includes packages for Unison version 2.13 (packaged as
unison2.13.16) if you need to use this older version of the software to interact with a specific client. Otherwise, install the more recent version of Unison, packaged as
Ubuntu 10.04 (Lucid)
/etc/apt/sources.list to enable to the Universe repositories, so that it resembles the following:
- File: /etc/apt/sources.list
1 2 3 4 5 6 7
## main & restricted repositories deb <http://us.archive.ubuntu.com/ubuntu/> lucid main restricted deb-src <http://us.archive.ubuntu.com/ubuntu/> lucid main restricted deb <http://security.ubuntu.com/ubuntu> lucid-security main restricted deb-src <http://security.ubuntu.com/ubuntu> lucid-security main restricted ## universe repositories deb <http://us.archive.ubuntu.com/ubuntu/> lucid universe deb-src <http://us.archive.ubuntu.com/ubuntu/> lucid universe deb <http://us.archive.ubuntu.com/ubuntu/> lucid-updates universe deb-src <http://us.archive.ubuntu.com/ubuntu/> lucid-updates universe deb <http://security.ubuntu.com/ubuntu> lucid-security universe deb-src <http://security.ubuntu.com/ubuntu> lucid-security universe
Finally, issue the following sequence of commands to: ensure that your system’s package database is up to date, that all installed packages are up to date, and install Unison:
apt-get update apt-get upgrade apt-get install unison
The unison packages for CentOS are not included in the base distribution, but are included in the EPEL repositories. Enable the EPEL repository, and ensure that your system is up to date and install unison with the following commands:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm yum update yum install unison227
The EPEL repository also includes a package for Unison version 2.13 in the
unison213 package. This may be helpful if you need to use this version of the client, otherwise use the more recent version of the software.
On Fedora systems issue the following sequence of commands to ensure that your system is up to date and then install Unison:
yum update yum install unison
Ensure that your local copy of the package database is up to date before installing Unison by issuing the following commands:
pacman -Sy pacman -S unison
Install Unison on Local Machines
In order to function properly, the major and minor version numbers of Unison used by the remote and local system must match. Test the version of Unison that was installed by the package manager on your Linode by issue the following command:
Use the information provided by the output of this command to aid in your decision on the appropriate version of your client.
If you are running a Linux-based system on your local machine you can install unison tools using the above procedures. If you’re running Debian or Ubuntu systems, you can issue the following command to install a graphical front-end for Unison:
apt-get install unison-gtk
Debian 5 (Lenny) also includes a graphical user interface for Unison version 2.13, packaged as
If you’re running OS X or Windows, download an appropriate Unison client. When successfully installed, provide the client with the resolvable address of the remote server, SSH keys or other authentication credentials, and the absolute paths to the local and remote folders that you want to synchronize. From now on, when you run Unison from the client app, changes to either or both of the specified file systems will be updated and reflected in both instances. Congratulations!