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
1
vote
1 answer

How to install unison-gtk in NixOS?

The title pretty much says it. I installed NixOS 20.03 in a virtual machine to play a little with it and, if all goes well, install it on my work laptop. I use Unison's gui, unison-gtk, to keep the laptop and my main production machine in sync. I…
Jeff
  • 953
  • 2
  • 11
  • 21
1
vote
0 answers

Unison with davfs

I'm trying to do bidirectional sync of the local directory and cloud storage with WebDAV access. I mounted cloud storage with davfs as local partition and tried to sync it with the local directory via unison with the following profile: batch =…
denis.che
  • 21
  • 5
1
vote
1 answer

Unison Sync Error, Contents Changed on Both Sides

I'm not sure why, but I keep getting this error when pushing some changes in Unison. Synchronization complete at 11:49:01 (0 item transferred, 2 skipped, 0 failed) skipped: /timetool/ana_combined (contents changed on both sides) skipped:…
NoVa
  • 317
  • 3
  • 15
1
vote
1 answer

Problems with whitespaces when syncing between Linux/Windows?

I'm using unison version 2.51.2 (ocaml 4.06.1) to sync files between a Synology NAS (BTRFS filesystem) and a Windows 2016 Server (NTFS filesystem). I'm trying to sync one-way from Linux to Windows using the -force option. I seem to experience some…
TylerDurden
  • 697
  • 1
  • 5
  • 16
1
vote
0 answers

How to fix Unison error in setting file ownership

Im trying to sychronize STOR1 and STOR2 on my linux device using unison. However when I try the following code; unison /srv/webdata/html ssh://172.16.3.12//srv/webdata/html -group -batch -silent I keep getting the following error; Failed…
1
vote
1 answer

How to install unison from source on macOS

I was wondering whether somebody managed to install unison's latest version from source, on its macOS machine (Here I am trying with Catalina). I followed the steps here : I verified that I had XCode installed (otherwise forget about compiling…
oscaroscar
  • 1,158
  • 11
  • 16
1
vote
1 answer

Resolve conflicts in favour of one root for all but a few dirs

I'm trying to use Unison to synchronize files between my host machine on Windows and my guest VM on Fedora Linux. I want all conflicts to be managed automatically: all conflicts must be resolved in favour of the host (Windows) by default a few…
BenMorel
  • 34,448
  • 50
  • 182
  • 322
1
vote
1 answer

Make Unison remember files that were synchronized although they have been deleted from one replica?

I'm currently setting up a synchronization task in Unison that should help me transfer data needed for working on the road from the desktop computer (location A) to my laptop (location B). For some of the data (in a specific directory) I would like…
Marcus C.
  • 219
  • 1
  • 3
  • 11
1
vote
1 answer

How to compile a static version of unison

On my OS X box, brew install unison gives me version 2.51.2. But the system I need to sync with runs CentOS 6.10 for which there appears to be no existing 2.51.2 binary. I also can't compile from source on that machine as it doesn't have the right…
Simd
  • 19,447
  • 42
  • 136
  • 271
1
vote
1 answer

How to get Lsyncd's file-watching capability with Unison's two-way sync?

I have used Lsyncd before, but it just works for one-way sync, so only the Master can copy files to the Slave server. I have found another solution for two-way sync between Master and Slave with Unison, but Unison doesn't watch for changes in…
1
vote
2 answers

Uncaught exception Failure("input_value: bad bigarray kind") - Unison on Windows and Mgt Development Environment

I am using the Mgt Development Environment (mgtcommerce/mgt-development-environment-5.6) on Windows 8.1. & DockerToolbox for Windows. I also downloaded the proposed versions of OpenSSH & Unison from…
toasty
  • 519
  • 1
  • 5
  • 12
1
vote
1 answer

Using Unison "-repeat watch" in FreeBSD (10.2) after installing from ports yields error

After installing unison from /usr/ports/net/unison with X11 disabled via make config, running the command unison -repeat watch /dir/mirror/1 /dir/mirror/2 Yields the message: Fatal error: No file monitoring helper program found From here I decided…
Tewan
  • 11
  • 2
1
vote
1 answer

Unison fails to backup hidden dotfiles

I am using unison (a file synchronization tool) to sync files between my linux machine (client) and a linux ssh server (host). It will synchronize dotfiles (config files that start with .) fine, but it doesn't create backups of them at all. Is this…
Mike Pierce
  • 1,390
  • 1
  • 12
  • 35
1
vote
3 answers

Unison source compile errors in OCAML

I am trying to compile the unison source using OCAML compiler(ver 4.01.0) and GNU make 4.0. The source code is taken from the link (http://www.seas.upenn.edu/~bcpierce/unison//download/releases/unison-2.27.57/) I extracted the tar.gz and then wrote…
hhs_89
  • 9
  • 4
1
vote
1 answer

Unison doesn't copy SYSTEM perm (cygwin/windows)

After using crashplan for a while, I noticed that several files aren't being backed up. The files are synced via unison (through cygwin) with another PC and while the *nix permissions are copied correctly, the mirrored file does not have SYSTEM as a…
Sandr
  • 11
  • 3