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://[email protected]//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://[email protected]//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

58 questions
15
votes
7 answers

Rsync that handles moves sensibly

I've been successfully using rsync to synchronize my home directories between my laptop and my netbook (both using ext4 with Linux). My only problem with it is that every now and then I like to completely reorganize certain directories, and rsync…
Petr Skocik
  • 28,176
  • 14
  • 81
  • 141
9
votes
1 answer

unison "end of file exception"

the few last days I am getting this exception when running unison: "End_of_file exception raised in loading archive" (this indicates a bug!) it does not help a bit, I cannot find answer elsewhere on google, ppl talk about it but seem not be able to…
Aquarius Power
  • 4,099
  • 5
  • 38
  • 56
7
votes
4 answers

Centralized $HOME for roaming devices - sync instead of NFS?

For over a decade now I have been working in a full Debian environment in my small office (currently 1 server, 7 users, 3 desktops, 4 laptops). Authentication is based on Kerberos, user profiles are managed in LDAP, and $HOME is served to all of the…
zenlord
  • 688
  • 1
  • 4
  • 15
7
votes
1 answer

How to fix unison failing with "Fatal error: Internal error: New archives are not identical" for identical paths?

When trying to sync two paths (one of which is remote) via ssh, unison fails with Fatal error: Internal error: New archives are not identical. while syncing via a network mount works just fine. While unison -debug all yields no indication on the…
Tobias Kienzler
  • 9,184
  • 13
  • 65
  • 106
6
votes
5 answers

Unison and version/compiler conflicts

I have two machines that one runs Ubuntu 18.04 and the other one Ubuntu 20.04. I want to use Unison to sync files between them but there are some issues. Firstly, because I sync with another machine too, I compiled from source Unison 2.48.3. Then in…
hal
  • 191
  • 1
  • 9
6
votes
3 answers

Unison "Fatal error during unmarshaling"

I have installed unison 2.48.4 on three machines, two running Linux Mint 17 and one Linux Mint 18. I sync via SSH. The two 17's sync with no problem. However the 18 cannot sync with either of the other two. The list of potential transfers is…
mathstranger
  • 61
  • 1
  • 2
6
votes
1 answer

Running `unison -repeat watch` yields filesystem watcher error

I'm trying to sync a folder in my host OSX to a VM running Ubuntu. (laravel/homestead). This is the command I run on my host: $ unison ssh://[email protected]//home/vagrant/www ~/unison/www -repeat watch which produces the following…
6
votes
1 answer

How to use multiple versions of unison on one system?

I have two machines. One with unison v. 2.40 (Debian Jessie) and a new one (Debian Stretch) where I installed package unison-all, which brought in unison versions 2.32, 2.40 and 2.48. However, I was unable to make my 2.40 work against the new…
Frigo
  • 222
  • 3
  • 8
5
votes
2 answers

Unison and extended file attributes

I have two machines, one Debian, one Ubuntu, both on ext4 with extended file attributes enabled in fstab. getfattr and setfattr are installed and work perfectly on both machines locally. However, unison (version 2.40.102) doesn't sync extended file…
4
votes
2 answers

How do I run unison between Ubuntu and CentOS 7

I am trying to sync data between an Ubuntu instance and a CentOS 7 instance. It's like a bi-directional rsync so I thought unison would be the best tool. I installed it on both instances but when I tried to connect them I received an error because…
jss367
  • 195
  • 7
4
votes
1 answer

Unison: Ignore all files with *.ext, except those in a specific subdirectory

I am trying to perform a sync using Unison (2.40.102) where I want to ignore all files with a specific extension, say *.ext, but not ignore the files with this extension if they are in a specific subfolder. Folder…
blsqr
  • 43
  • 1
  • 5
3
votes
3 answers

Backup and synchronization

I want to synchronize my personal document repository between my different computers in my home. Today this folder is under a dedicated partition of the hard drive of a dual boot workstation. My configuration is the following one: Dual boot…
Manuel Selva
  • 3,454
  • 7
  • 20
  • 17
3
votes
1 answer

Can unison be made to preserve file creation dates?

unison is a very useful tool to synchronize filesystems, for instance between different machines. It detects conflicts and asks the user about them before actually copying anything (user then decides which version of the file to copy into the other,…
Dalker
  • 1,582
  • 1
  • 11
  • 16
3
votes
3 answers

How to sync bidirectionaly 2 folders between a Synology Nas and a Debian computer?

I found two starting solutions: use Unison, but I found no way to install this package on a Nas Synology via DSM. use Cloud Station Drive, but Synology only propose packages for Fedora and Ubuntu and I don't found an URL package source to install…
Klemart3D
  • 73
  • 2
  • 7
3
votes
3 answers

Decreasing hard drive sync time with Unison

I'm using Unison to synchronize my music collection to a few different sources, namely a couple computers over SSH and a hard drive. One thing I've noticed is that SSH updates are incredibly fast in comparison to hard drive syncs, possibly because…
Naftuli Kay
  • 38,686
  • 85
  • 220
  • 311
1
2 3 4