Synchronize Files with Unison on Ubuntu/Debian
Unison is a free, cross platform file synchronization tool that enables us to keep two set of file replicas (instances) on two different systems or on different disks of the same system. Unlike simple mirroring or backup utilities, it updates both replicas of a distributed directory structure. It detects and displays the conflicting updates. Unlike a distributed filesystem, Unison is a user-level program; there is no need to modify the kernel or to have root user 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.
In this how-to i am using two systems running with Ubuntu. The local system is running with Ubuntu Desktop and its ip address is 192.168.1.100/24 and remote one is running with Ubuntu Server and its ip address is 192.168.1.201/24. And i am going to synchronize the directory /home/sk/Unixmen between two systems. Change the values as per your scenario.
On Local & Remote Server System:
Update and Upgrade the both systems with following commands.
sudo apt-get update sudo apt-get upgrade
Install Unison on both systems.
sudo apt-get install unison unison-gtk
Now on your local system, launch the Unison GUI tool from Menu or Dash. It should look like below.
Here you will be prompted for Synchronization method. I want to synchronize the files between my local desktop to remote server using SSH. So here i choose Using SSH from the Synchronization Kind drop-down box. Enter the remote host server ip address and user name as below and click Forward.
Now we have to mention the local and remote folders to be replicated. Enter the local folder path in the Local Directory (i.e in my case its /home/sk/Unixmen) box and Enter remote folder path in the Remote Directory box. Click Forward.
Now check for the files in your remote system. They certainly should be there. If you added a new file or directory click Rescan, after that click Go to start the sync.
sk@server1:~$ ls /home/sk/Unixmen/ New1 New2 New3
Thats it. Enjoy. Here what you have just read is a basic concept of Unison. You can do lot of things using Unison. I suggest you read the official documentation for more information.