Questions tagged [unison]

Unison is a bidirectional, conflict detecting file-synchronization tool for OSX, 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.

Overview

Unison is a file-synchronization tool for OSX, 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, Subversion, BitKeeper, 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 and many flavors of Unix (Solaris, Linux, OS X, etc.) systems. Moreover, Unison works across platforms, allowing you to synchronize a Windows laptop with a Unix server, for example.

  • 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.

  • 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.

  • 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 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 has a clear and precise specification.

  • Unison is free; full source code is available under the GNU Public License.

Usage

The first time Unison is run, it will take some time to fully synchronize the specified directories. It will create archive files in the .unison directory ($HOME/.unison in Unix, $USERPROFILE\.unison in Windows) to store the structure of the sync directories and make future syncs much quicker.

Unison can be run in a very basic way by evoking it as unison [options] root1 root2 where root1 and root2 are the directories to be synced. To more easily run Unison with many options and to more easily evoke Unison from within a script or as a cron job, it is convenient to create a profile to specify the roots of synchronization and other options. If we have a profile profile.prf (stored in the .unison directory), we can use this profile by running unison profile. A simple profile will look something like this:

# profile.prf
root = /home/user
root = ssh://user@198.51.100.42//home/user
path = Documents
path = Files

This will synchronize the local directories /home/user/Documents and /home/user/Files with the corresponding remote directories on 198.51.100.42 over ssh.

A more interesting Unison profile that could be used for automating backups to a remote server could look something like this:

# profile.prf
root = /home/user
root = ssh://user@198.51.100.42//home/user
sshargs = -C -i /path/to/ssh_key

path = Documents
ignore = Path Documents/secrets
ignore = Name *.tmp
ignore = Name {.*,*}.sw[ponx]

auto = true
batch = true
confirmbigdeletes = false

backuplocation = central
backupdir = /home/user/Unison-Backups
maxbackups = 7
backup = Name {.*,*}
backupprefix = .$VERSION

This profile will sync all of /home/user/Documents to the remote server except for the /home/user/Documents/secrets subdirectory, all files with a .tmp extension, and any swap files that vim likes to create. It will also automatically sync files without asking for confirmation (auto = true) and will store backups of files that are overwritten when they are synced in /home/user/Unison-Backups.

Helpful Links

Unison Homepage
User Manual and Reference Guide
A good Unison guide by Philip Guo

51 questions
15
votes
5 answers

Synchronizing very large folder structures

We have a folder structure on our intranet which contains around 800,000 files divvied up into around 4,000 folders. We need to synchronize this to a small cluster of machines in our DMZs. The depth of the structure is very shallow (it never…
MightyE
  • 251
  • 2
  • 6
6
votes
1 answer

Is there a global config file for Unison synchronization tool?

I'd like all my unison profiles to have merge = Name * -> meld CURRENT1 CURRENT2 diff = /usr/bin/meld CURRENT1 CURRENT2 confirmmerge = true as options. I know I can add these options to each .prf files in ~/.unison/, but having a global config file…
5
votes
3 answers

lsync, unison or some other inotify auto-syncing tool..?

I have an app farm which generates thumbnails and makes them available to a web server farm using nfs. However the performance is so poor so I am going to make a local copy of the files on each web node. I looked at unison and lsync, but there…
Tom
  • 10,886
  • 5
  • 39
  • 62
4
votes
2 answers

Remotely use root over ssh for unison

I'm a little confused on how to run unison to sync files with group and owner attributes on an ubuntu system, as you need to be root. But I need to do this remotely and automated. I know I can set up ssh keys and the such for my user but that…
Elgoog
  • 215
  • 3
  • 6
4
votes
4 answers

Solution for two-way file-system transparent solution

I need to implement some sort of HA setup where 2 servers need to be able to always be in sync, no matter on which one you write on. The DB part can be covered by a master-master replication setup. However, when it comes to files and content I…
3
votes
0 answers

Unison sync of sshfs mount - what can go wrong if the connection breaks?

I am syncing a local directory (say "/local") with a cloud storage server using Unison. The cloud storage is mounted to, say, "/mnt" via sshfs (with no-cache option), and I sync the two directories /local and /mnt with Unison locally. [I don't have…
André
  • 131
  • 2
3
votes
2 answers

Using Unison / rsync over SSH to synchronize sites where full file system access is required yet root login is disabled

Assume two sites A and B with file server at either end. The contents of /storage should be synchronized between the sites, preserving ownership and permissions. There's no all encompassing group that group-owns all of the files in /storage. If…
datenwolf
  • 259
  • 1
  • 9
3
votes
1 answer

Linux bidirectional file sync over a WAN with immediate/incremental syncing

Does anyone know of a solution that lets you sync files bidirectionally over a WAN, but also syncs immediately/incrementally? Basically Unison is perfect for the file syncing, but it doesn't sync incrementally - it will wait for a file to finish…
AndyC
  • 233
  • 4
  • 14
3
votes
3 answers

Run unison in background on startup?

I'm running Debian 6 64bit. What I'm trying to do is run Unison on startup to constantly monitor files on the LAMP server I have running on my VM and sync that with the VM Shared folder. while true do unison -batch -owner -group /folder1/…
mawburn
  • 187
  • 1
  • 12
2
votes
1 answer

Installing unison on Redhat

I can't seem to manage to install unison on red hat 7.2 tried multiple tutorials such as this one http://www.tecmint.com/file-synchronization-in-linux-using-unison/ I Have epel enabled But: sudo yum install unison sudo yum --enablerepo=epel install…
Boaz
  • 375
  • 1
  • 9
  • 16
2
votes
1 answer

Unison / file syncing between servers without using root account

I have setup 3 servers one with a load balancer and the other 2 will host the websites files and I have a replicated MySQL database on both too. I have installed ispconfig on both and it's set to mirror one of the server and everything is working…
Kravitz
  • 157
  • 9
2
votes
1 answer

Getting a simple list of changed files from unison

I have a filesystem that is changed on two servers and also needs to be replicated to Amazon S3. Until recently, syncing the filesystem between the two servers using Unison, and then copying to S3 with s3sync.rb has been a fine solution. Now that…
jaygooby
  • 295
  • 1
  • 2
  • 12
2
votes
1 answer

Unison File-Synchronizer

I currently have Unison installed as a one way sync (mirroring) between a CentOS/Win7 box. When configured as a one way sync what happens if I change a filename on the source box? Will unison delete the file on the mirroring box and then recopy the…
Nick M.
  • 351
  • 1
  • 6
  • 12
2
votes
2 answers

Boot and/or synchronise linux image from network

I'm looking for a solution (or at least for some guide/pathway/manual) to boot AND SYNCHRONISE Linux images from network. I already understand how network boot (PXE, DHCP, TFTP) works. In my organisation we have many PC's with the same (or different…
Andrey Sapegin
  • 1,191
  • 2
  • 11
  • 27
2
votes
1 answer

How can I tell unison to first delete files and then to copy changed ones?

Unison sorts changes in order to first add new files and then to delete removed files. When I use it to synchronize 2 USB drives, I can have problems with that if there's no room enough in the drives to store new staff without deleting first removed…
Luca Borrione
  • 725
  • 2
  • 9
  • 16
1
2 3 4