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

53 questions
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
  • 755
  • 2
  • 9
  • 16
2
votes
3 answers

Recommended networked file system for web servers?

If I have two web servers, what would the best way to keep their files in sync? Unfortunately the sites themselves cannot be altered significantly. Most of them are Wordpress based, but there are over 200 of them. There are also some custom…
Nick
  • 287
  • 1
  • 10
2
votes
2 answers

Watching for Unison errors

We've implemented a folder sync across two servers sitting in two different data centres using Unison. It's crucial for us that this folder sync work as expected as our SLAs depend on the data being available at both ends. So far Unison has been…
2
votes
2 answers

how i can disable delete file option in unison sync tool?

i want to disable delete option of unison in other word i want unison tool always copy file [don't delete anything]. I read manual but i can not find what i need . for example we have two folder folder1 and folder2 1- the first time :- folder1…
2
votes
3 answers

sync a directory between OSX and Ubuntu

I need a good way to sync a directory between my OSX 10.6 laptop and my Ubuntu Desktop. Dropbox would obviously be a great choice, however the directory I need to sync is owned by root on both machines and fixing the permissions would screw up the…
Erreth
  • 71
  • 1
  • 4
2
votes
1 answer

Is there a way to replicate a very large file shares in real-time?

I have an hourly cron job that copies about 40GB of data from a source folder into a new folder with the hour appended on the end. When it's done, the job prunes anything older than 24 hours. This data changes very often during work hours and is on…
fsckin
  • 573
  • 4
  • 9
2
votes
0 answers

Unison synchronization problem. Roots are not identical after synchronization

When I synchronize two folders using Unison, only one of the roots seems to be affected. Below are all the information I would think is necessary to figure out why it is working like it is. I'm using $ unison -version unison version 2.27.57 From…
Deleted
  • 1,832
  • 8
  • 23
  • 31
2
votes
1 answer

Create SSH user for Unison with the fewest rights

I would like to share a directory on my server so that a colleague can synchronize it via Unison (two ways synchronization). I don't want him to be able to read files on the server via ssh access. It would be best if the ssh user can't log in, but…
br0ken.pipe
  • 167
  • 2
  • 9
1
vote
0 answers

Is there a way to force unison to either split jobs or use less RAM?

I want to use Unison to sync 2 file systems of about 2.5TB, but every time I try to sync, the host on which I run the job kills it (OoM kill) because it uses a ridiculous amount of memory. (The host runs Ubuntu and has 6GB RAM and 2GB SWAP) Is there…
1
vote
1 answer

Root user takes unison profile from regular user?

I have two unison profiles with the same name as following: /root/.unison/theprofile.prf /home/users/itsme/.unison/theprofile.prf Both have different contents. They target the same remote server (over SSH), but have their own directory on that…
itsme_now
  • 13
  • 2
1
vote
1 answer

unison with inoify watch: how does it deal with frequent changes to the same file(s)?

Supposing I have one relatively large file synced by unison. And the file changes for some time more frequently than unison is able to sync it. Does it squash subsequent changes or tries to queue and send every single version? Is it possible to…
ardabro
  • 187
  • 1
  • 7
1
vote
1 answer

unison-fsmonitor doesn't detect any changes

I've just compiled unison 2.48.4 for my own. It works perfectly after normal call but unison-fsmonitor doesn't deect any filesystem changes and doesn't synchronize anything. Filesystem is EXT4. -debug all/verbose doesn't bring any log. The only…
ardabro
  • 187
  • 1
  • 7
1
vote
0 answers

Unison: should I use a remote shell (ssh) or VPN tunnel?

We have 2 office locations. Each LAN is connected via a site-to-site OpenVPN tunnel. Office1 has an Ubuntu Server; samba file shares; OpenSSH server; Unison File Synchronizer. Office2 has a Win Server 2012R2; replicated copies of the same file…
dan
  • 279
  • 1
  • 4
  • 15
1
vote
0 answers

Unison: skip any delete of files or folders

While synchronising directories using Unison I want to skip any delete of files or folders (both ways). I wonder how I can do it?
user333261
1
vote
2 answers

Using Unison repeat = watch on CentOS7 "Fatal error: No file monitoring helper program found."

So after installing Unison on CentOS 7, i wanted to use the repeat=watch function. syncing by running unison manually works perfect. But for a auto-sync on change, repeat=watch could be used. But this line gives me the error: Fatal error: No file…
Lars Behrens
  • 53
  • 1
  • 6