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

36 questions
11
votes
3 answers

Can I install Unison for Ubuntu 18.04 LTS on Ubuntu 20.04 LTS?

I have two machines running Ubuntu. One runs Ubuntu 18.04 LTS and the other one runs Ubuntu 20.04 LTS. I want to use unison to sync files between them. I've installed unison on both of them the conventional way. I.e.: sudo apt install…
Free Radical
  • 449
  • 1
  • 7
  • 21
7
votes
2 answers

Unison - Automatically Sync Computers

Is there a way two sync multiple computers (i.e. particular directories in the home folder) automatically using Unison? If not, is there an alternative that can do this? I'm not completely against opening Unison all the time and doing the sync…
Nateowami
  • 1,585
  • 4
  • 18
  • 30
5
votes
3 answers

How to install Unison 2.40 on Ubuntu 16.04 xenial (to resolve "Fatal error: Received unexpected header")

On my other computers I have unison version 2.40.102 (this is the latest version available), and on my desktop ubuntu 16.04 xenial I have unison version 2.48.3. When trying to synchronize: kayd@Trunk:~$ unison . ssh://pi@mizu/. ... Fatal error:…
kay_D
  • 394
5
votes
1 answer

Unison - how to make it sync automatically (bidirectional)

I have a folder music on my HDD and folder Music in external HDD. I want these 2 folders to be synced (ie if I add/remove/edit something in one folder, the changes immediately reflects in another). I think that Unison could do this but I'm…
Milano
  • 643
  • 3
  • 12
  • 24
4
votes
1 answer

Keep a folder on my computer in sync with a folder on my android device

A simple requirement over which I am breaking my head! I want to keep a folder on my computer in sync with the folder on my android device. There are times when the file on the computer will be 'new' and times when the file on the Android device…
deshmukh
  • 4,121
4
votes
3 answers

Unison repeat=watch file limit?

I'm running Ubuntu 14.04, when trying to sync a directory with Unison using the option repeat=watch. The directory contains ~125K files but I'm abutting a limit on the number of files Unison can handle. This is the error I receive: Fatal error:…
4
votes
1 answer

Has Unison error on "File name too long"

I'm using Unison for backup/file replication. Unison has a problem with long file names - it does not sync files with long names Error: Failed: Error in querying file information: File name too long Over here the developer says about plans to…
4
votes
3 answers

How can I exclude all the svn metadata while synchronizing with unison?

How can I exclude all the svn metadata while synchronizing with unison? So that all subfiles/folders are also ignored! Thank you for you help
4
votes
0 answers

Synchronize SSHFS mount with local filesystem

I've got a directory called "secure" that I mount on my laptop via sshfs whenever the server is in reach. While this server is in reach I want to keep it in two-way sync with a directory called "sync". The "secure" directory is mounted with…
d_inevitable
  • 1,922
3
votes
0 answers

Is there an overlay file system doing a copy-up on read?

What I‘m looking for is a mixture of an overlaying file system like overlayfs or aufs that does a copy-up on read access. Or, from the other side, a service like unison that sync only files that have been requested so far. You could call it a cache,…
undko
  • 131
3
votes
1 answer

Save only specific output to log file

I'm using unison to synchronise data to a server, and I've recently created a cronjob for this. The cronjob is running at startup and saves the output to a log file. (additional info below). The problem I'm having is that unison has quite a lot of…
ElRudi
  • 299
3
votes
2 answers

syncronizing with unison on ubuntu

I'm trying to sync two ubuntu machines using unison. Unfortunately the documentation for this program is not terribly helpful. Also there doesn't seem to be an established forum. So I'm hoping somebody here has used it. When I sync for the…
Leo Simon
  • 1,549
3
votes
2 answers

Why does ubuntu have a separate package for unison version 2.27.57?

The current ubuntu repo contains an extra set of packages for version 2.27.57 of the unison file sychronization utility: $ aptitude search unison p unison - A file-synchronization tool for Unix and W p unison-gtk …
intuited
  • 7,375
3
votes
3 answers

Unison shows error about locked archives

I have installed Unison to sync data between my two PCs but I am getting an error about a non existing file. Here it is there is no such file in the .unison folder called lkb60...... which is being complained.
3
votes
1 answer

Can Unison transfer the executable flag?

I create a Unison setup between my work computer and my desktop at home. This way, I can continue my work at home (and vice versa), even when I forgot to commit something to GIT at work (and vice versa). In my Unison profile, I am using the…
1
2 3