I think that a lot of computer user are now used to the concept of copy on the “Cloud”, with tools like Dropbox or Ubuntu One, you can have the same file saved in multiple computers (also with a different operating system) and at the same time have a copy of it on the Cloud.
Usually you get some free space to start and if you need more you have to pay a monthly or yearly price, but these concepts where already there and available for Linux with Unison.
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.
The latest stable version, is 2.40.63. It is available as source code and precompiled binaries for Linux, Win32 and Mac OS X.
Some features of Unison are:
- It runs on many operating systems, and can synchronize files across platforms, so that for instance a Windows laptop may be synchronized with a Unix server.
- It detects ‘conflicts’ where a file has been modified on both sources, and displays these to the user
- It communicates over the TCP/IP protocol so that any two machines with an internet connection can be synchronized. This also means that the data transferred can be secured by tunneling over an encrypted SSH connection.
- It uses the rsync algorithm developed by Andrew Tridgell. This algorithm transfers only the parts of a file that have changed, and so is faster than copying the whole file.
- It is designed to be robust in the event of a program or system crash or a communication failure.
- It is written in the Objective Caml language.
Unison on Ubuntu
For my test i’ve used my Ubuntu 11.10, but the concepts are the same on all Linux Distributions.
Unison it’s available in the Ubuntu repository so you can install it with the command:
sudo aptitude install unison unison-gtk
Unison-gtk it’s an handy gui for Unison, so i suggest to install it.
The first time you run the program a wizard will ask you to select a local directory and a second directory that can be local to your computer or remote (rsh and ssh supported). This will create your default profile.
Different sync jobs in Unison are called ‘Profiles’. For example, you may have a profile that synchronizes your music folder between two computers on a network, and another profile that synchronizes files between two drive.
Choosing a profile
When you start Unison, you will be asked which profile you would like to use.
To change the profile you are using while inside Unison, go to Synchronization -> Select a new profile from the profile dialog, or press P.
From this windows there is also the option Create New profile that allow to create a new profile with the same wizard that we have used in the first run.
Although the basic operation of Unison are 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 or resolve all conflicts in favor of the second. Also, you can force all changes from one directory to another and replace older files with newer ones.
Using Unison from the command line
Unison can be used from the terminal.
The basic usage it’s
unison directory1 directory2
The following is a simple example to synchronize a music directory between two folders on the same computer:
unison /home/myhome/Music /backup/Music
Or if a profile has been created you can use the syntax:
Unison it’s an useful tool when you want to keep 2 copy of your files on your computer/server, it’s really easy to set it up with the graphical tool, and you can use the command line to set up cron job, like” syncronize my document directory every 2 hours”.
I found it useful for these situations, i use it to sync a directory from my laptop to a big USB disk attached to my desktop via ssh.
And to save another directory from my desktop to that USB disk.
Thanks to a cron i’ve forget to worry about this, and i’m sure to haev a backup copy of some directory i want to keep safe and in 2 copies.
- arkOS: build your Cloud with a Raspberry Pi
- Linux Games: Faster Than Light
- Review and repair a Linux SWAP Partition
- Introduction to Vagrant – Part 1
- Turpial 3 – The best microblogging client is back ?
Find me on Google+