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

102 questions
27
votes
3 answers

Using MySQL and Mongodb together

I have worked with MySQL more than MongoDB, but from what I've learned from MongoDB it's just what I needed, but it also has it's limitations that MySQL can do (for instance auto increment) Would it be smart to use MongoDB for everything, and use…
WittyPleb
  • 553
  • 2
  • 10
  • 22
16
votes
1 answer

How to install a specific version of ocaml compiler with opam

How can I install a specific version of ocaml compiler (and compatible packages) using opam (or another package manger)? I took a quick look through the opam documentation, but I don't find a relevant information. I need ocaml compiler (preferably…
norio
  • 3,652
  • 3
  • 25
  • 33
14
votes
1 answer

unison "-repeat watch" not working

I recently installed unison on my home machine (OSX 10.9) and on my remote server (Ubuntu 12.04 64-bit). I have version 2.40.102 installed in both place. I used 'brew install unison' on my Mac, and I compiled from source on the server. The issue is…
Scott
  • 2,557
  • 5
  • 26
  • 32
11
votes
3 answers

How to use unison across OS X and linux? Fatal error due to ocaml version

I am trying to use unison from my OS X machine to a linux box running: CentOS release 6.10 (Final) I had to make a static compilation of unison 2.51 for the linux box. This version is: unison version 2.51.2 (ocaml 4.02.3) On the OS X machine I…
Simd
  • 19,447
  • 42
  • 136
  • 271
11
votes
5 answers

Unison: sync only in one direction

If I have folder A and B, is it possible to sync the new files from A to B and to not erase in B files erased in A? That is to say, I would like to use B as a big container for any file, including the one that I once synchronized from A and than…
Chamaeleon
  • 125
  • 1
  • 6
11
votes
2 answers

Sync directories containing git repository with unison

I want to sync a directory containing a git repo of my dotfiles on two machines. Both machines will make changes to the files in the repo. Normally I use unison for syncing directories but in this case the files in the .git directory diverge even…
Praxeolitic
  • 22,455
  • 16
  • 75
  • 126
10
votes
3 answers

Unison fails with "ill-formed message" error, same remote & local versions

I'm trying to get unison working after upgrading to Mac OS X Catalina. Unfortunately, macports installs a more recent version of ocaml (4.08.1), which means that the unison 2.51.2 release won't compile. Well, that's no problem, I just update to git…
John Clements
  • 16,895
  • 3
  • 37
  • 52
8
votes
3 answers

Ignore everything in a directory except one subfolder

I have a directory ~/x7/music/sfx. There are some files and folders in the root of ~/x7/music. I need to sync only the sfx folder and ignore anything else in music. I've tried many variants, but all of them was wrong. ignore = Name…
det
  • 81
  • 1
  • 3
7
votes
7 answers

How to keep an eclipse workspace synchronized among two machines?

I have nearly identical Linux (Fedora) machines at home and at work and I keep my files on both machines synchronized using the excellent Unison program. I have been trying to keep an eclipse workspace synchronized across the two machines but this…
Jose M Vidal
  • 8,816
  • 6
  • 43
  • 48
6
votes
2 answers

Unison preserve directory time

In the Unison (two way file syncing program) manual, when you set the -times=true preference, only the time stamps of the files are kept unchanged, not the directores: From the Manual: times When this flag is set to true, file modification times…
makhlaghi
  • 3,856
  • 6
  • 27
  • 34
6
votes
6 answers

Why does `.git/index` change when I haven't done anything to my repository?

With the latest Debian version of git (I'm using 1.7.2.5), I've noticed that a .git/index file may change mysteriously, without my having performed any operation that I feel should change the repository. (My shell occasionally runs git branch so it…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
5
votes
3 answers

Unison sync between Windows/Linux hangs randomly during transfer

We regularly deploy interactive kiosk CPUs to remote phsyical sites, and I've developed a content updater application that performs a nightly sync of media assets between each kiosk (Windows 7 Pro) and a hosted CMS (virtualized Ubuntu server running…
5
votes
1 answer

How does one use the "matching condition" commands for the unison cli?

The interactive unison command line provides the following help: Commands: or f or follow unison's recommendation (if any) n or j go to the next item p or b or k go back to previous item or
Ben Whale
  • 493
  • 2
  • 9
5
votes
1 answer

How to properly setup docker-sync to exclude folders

I am trying to setup docker-sync to exclude my app/cache and app/logs folder but it is not working. Things I've tried: Using sync_excludes: ['.idea', 'app/cache/', 'app/logs/'] but it will be translated to something like this command unison…
neisantos
  • 492
  • 1
  • 5
  • 16
5
votes
1 answer

What is the difference between the Unision options `prefer=newer` and `force=newer`?

A piece of the Unison manual for force: You can also specify -force newer (or -force older) to force Unison to choose the file with the later (earlier) modtime. In this case, the -times preference must also be enabled. My understanding is that…
ardabro
  • 1,907
  • 16
  • 31
1
2 3 4 5 6 7