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
5
votes
1 answer

How does unison decide which way to sync a file

I am using unison to sync a bunch of folders together. Not just 2 roots, but I think my question can be made this simple... Lets say I am syncing directory A and B using unison. If I remove file X from directory A, how does unison know what to do?…
Jono
  • 1,690
  • 2
  • 18
  • 29
5
votes
4 answers

How to trigger unison sync files and directories when there's any change on OSX?

I have a need to sync two directories on OSX. I find this post recommending using unison. I tried unison, it seems it can sync two directories very well. But it doesn't do synchronization automatically( always keep two directories synced when…
Aaron Shen
  • 8,124
  • 10
  • 44
  • 86
5
votes
1 answer

File sync with node.js: unision== tcp==node-----[http]-----node==tcp==unison

If you have node running and I have node running, has anyone seen a solution that will allow us to keep a set of files in sync. Synchronisation is complicated, so I thought that could be left to a tool like unison (which is like rsync) and then all…
5
votes
2 answers

ssh using python without RSA keys

New to Stackoverflow, so first off, hello. I'm working on a little project for my school which is supposed to be a custom gui (written in python as an educational challenge for me since I've never used python) for the open source Unison program.…
Jtgrenz
  • 591
  • 1
  • 6
  • 21
4
votes
1 answer

unison star topology

How exactly does unison star topology work? I sort of understand the concept that one machine acts as the HUB where every spoke syncs to it but is it just a concept and I have to implement it on my own or is this some kind of feature built into…
user391986
  • 29,536
  • 39
  • 126
  • 205
4
votes
2 answers

Development Environment with Git + Unison

Is anyone using Unison (http://www.cis.upenn.edu/~bcpierce/unison/) to keep development projects consistent between laptop and desktop or similar? I'm worried Unison may butcher my git repos. Given MyProject, with the laptop checked out on…
Brian
  • 8,791
  • 3
  • 15
  • 9
4
votes
2 answers

Running External Apps on save in Eclipse

Since we cannot setup Eclipse's RSE to use at the tool for remote editing, I have installed Unison. But how can I get Eclipse to automatically run unison on every file save? Is there an eclipse plugin available for this? TIA
Gregory
  • 1,479
  • 15
  • 22
3
votes
1 answer

Unison's "ignorenot" parameter does not work

I have the following instruction in my unison profile: ignore = Path node_modules ignorenot = Path node_modules/scaffold Easy enough, right? Except that it doesn't work. It keeps on ignoring the node_modules/scaffold folder. I even tried it with a…
Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142
3
votes
1 answer

Exclude everything under folder *but* certain filetypes (at any nesting level)

Using version 2.51.2 (ocaml 4.04.0). Trying to exclude a folder at the root (called build), but include any files ending in .err and .out at any depth underneath it. Structure looks…
akevan
  • 691
  • 1
  • 9
  • 21
3
votes
1 answer

unison: how to sync specific subfolders in several directories?

I am trying to sync a subset of my directories between two machines (both ubuntu 16.04) with unison (version 2.48.3). On both machines, I have a directory called "research". It contains a folder for each project that I am working on. Within each of…
chris
  • 53
  • 1
  • 7
3
votes
1 answer

How to sync files without having Unison installed on the remote server?

Can I push files from a source to a destination using Unison with Unison installed on the source machine but not on the destination machine?
pramod
  • 117
  • 1
  • 9
3
votes
1 answer

Setting to follow Unison's recommended action

I use unison to sync a couple of directories between my laptop and desktop. Whenever there are new files on one system, I have to confirm each one individually: <--- new file c [f] I've scoured through the docs, but I can't seem to…
Christopher Pickslay
  • 17,523
  • 6
  • 79
  • 92
3
votes
2 answers

Unison move root with rootalias

I changed the mounting point of the harddrive with my replica from /media/frisch/DATEN/Dok-Daniel/ISAS to /mnt/DATEN_SSD/ISAS When I want to synchronize this, Unison says Warning: No archive files were found for these roots, whose canonical names…
Daniel1000
  • 779
  • 4
  • 11
3
votes
0 answers

Unable to get Unison to sync current folder onto remote folder

I am trying to automate backup of my project folders through a script. I found Unison, which seemed to match my needs, and have writtenm a script that can reliably mount and unmount a samba folder (Mac backing up to a Windows box). The only problem…
river226
  • 73
  • 12
3
votes
5 answers

Unison command not found

Recently my Unison application has stopped working on my Mac terminal saying the command cannot be found. Not sure if this was the reason but I recently reinstalled brew (which is how it was installed), which may have broken it. Here is the error…
InvalidSyntax
  • 9,131
  • 20
  • 80
  • 127