Unison PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Bart Dorlandt   
Wednesday, 30 January 2008 22:20

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.

Unison shares a number of features with tools such as configuration management packages (CVS, PRCS, etc.), distributed filesystems (Coda, etc.), uni-directional mirroring utilities (rsync, etc.), and other synchronizers (Intellisync, Reconcile, etc). However, there are several points where it differs:

 

  • Unison runs on both Windows (95, 98, NT, 2k, and XP) and Unix (OSX, Solaris, Linux, etc.) systems. Moreover, Unison works across platforms, allowing you to synchronize a Windows laptop with a Unix server, for example.
  • Unlike a distributed filesystem, Unison is a user-level program: there is no need to modify the kernel or to have superuser privileges on either host.
  • Unlike simple mirroring or backup utilities, Unison can deal with updates to both replicas of a distributed directory structure. Updates that do not conflict are propagated automatically. Conflicting updates are detected and displayed.
  • 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.
  • Unison has a clear and precise specification, described below.
  • Unison is resilient to failure. It is careful to leave the replicas and its own private structures in a sensible state at all times, even in case of abnormal termination or communication failures.
  • Unison is free; full source code is available under the GNU Public License.

A link to where you can download unison and find all the information. For a comparison between Rsync and Unison, take a look here.

I use for a bunch of documents and settings. Here is a config file located in the .unison directory in your homedirectory. Actually there are at least two files. One is the default.prf and one is the file.prf which includes the default when you load it.

Default.prf

# Unison preferences file
#diff = diff -y -W 79 --suppress-common-lines
backup = Name *
maxbackups = 0
log = true
logfile = /home/bart/.unison/unison.log
rshargs = -C

#silent = true
times = true

Here is an example of my home backup file

# Unison preferences file
root = /home/bart
root = ssh://dipsy.bamweb.nl//home/bart
# exactly two or none "root" lines

# Paths to synchronize
path = .acetoneiso
path = .cairo-dock
path = .config/gns3.ini
path = .config/compiz.ini
path = .config/pcmanfm.ini
path = .gftp
path = .gns3
path = .gnome2/stickynotes_applet
path = .gtodo
path = .liferea_1.4
path = .nero
path = .nerorc
path = .passwdsafe
path = .purple
path = .mozilla-thunderbird/default/ImapMail/mail.bamweb.nl/msgFilterRules.dat
path = .mozilla-thunderbird/handtekening
path = .unison/bart

path = belastingdienst.nl

# Path to ignore
ignore = Path .gftp/cache
ignore = Path .liferea_1.4/mozilla/liferea/Cache
ignore = Path .liferea_1.4/cache
ignore = Path .purple/logs

include default
# imports settings from default.prf

I have several files I want to backup. So I use a combination of a script and crontab. Here is my script.

#!/bin/sh
# Author: Bart Dorlandt
cd /home/bart/.unison
FILES=`ls -1 *.prf | grep -v -e default -e template | cut -d"." -f 1`
for x in $FILES
do
  echo ""
  echo update the following scheme: $x
  unison $x -batch
done

and here are the rules I use in the crontab. I use some grep commands to filter the output, so if I want to see if anything went wrong (failures), I just see that specific output.

@reboot sleep 20; /home/bart/scripts/backup/unison.sh > /tmp/unison-output.log 2>&1
0,15,30,45 * * * * /home/bart/scripts/backup/unison.sh > /tmp/unison-output.log 2>&1
1,16,31,46 * * * * cat /tmp/unison-output.log | grep -e scheme -e complete -e Nothing > /tmp/unison-output1.log ; mv /tmp/unison-output1.log /tmp/unison-output.log

Last Updated on Sunday, 13 July 2008 17:09
 


Related items: