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

72 questions
20
votes
6 answers

How reliable is Unison? Did it ever ruin your data?

I am interested in facts, when using unison ( http://www.cis.upenn.edu/~bcpierce/unison/ ) ruined your data? I want to find out about its reliability.
18
votes
1 answer

How to make unison ignore all files with .swp extension

How to make unison (file synchronization) to ignore files with .swp extensions? what should i add on the prf file?
Kokizzu
  • 1,807
17
votes
4 answers

How to use unison's path option with multiple paths?

I want to sync the following locations using unison: /home/user/Audiobooks with /shared/Audiobooks /home/user/Music with /shared/Music /home/user/Podcasts with /shared/Podcasts What would the unison command line parameters be? Based on this, I can…
MountainX
  • 2,214
14
votes
4 answers

make rsync wait for a confirmation before actually changing files

I am making a synchronization between a local and a remote folder. It happened that I lost one file by a stupid command. I am used to unison and to the way you confirm ("go?") before doing the actual file transfer. Is there such an option with…
meduz
  • 357
13
votes
5 answers

One-way syncing/backup with Unison

I'm using the syncing tool Unison with my Mac OSX and Ubuntu 9.10 machines to backup my music from Mac to Ubuntu. The thing is, I want to have my Mac be the source and Ubuntu be the target so that the Ubuntu machine will be an exact copy of the…
roflwaffle
  • 1,820
12
votes
2 answers

How do I ignore folders and its subdirectories in Unison sync

I use Unison to sync website projects across my machines, in one of my machines I would like to avoid sycning (both ways)some folders contained with in the folders I watch: /vendor /node_modules /storage/debugbar /staroge/framework This is the…
Imran
  • 455
9
votes
2 answers

How to sync only one file type with Unison?

Let's say that I want to sync a folder with unison, but I want to sync only .jpg files. How I could do that?
Magnetic_dud
  • 3,702
9
votes
1 answer

Unison not ignoring paths

I'm trying to ignore .git, .bundle and node_module directories from my sync. I've tried a heap of different combinations trying to get it to work but every time I sync I can see all of those directories syncing over to the remote machine. Can anyone…
Marklar
  • 384
8
votes
1 answer

Making unison ignore file property differences

I'm trying to use unison (the GUI) to synchronize two folders; unfortunately, one of them is a Windows drive mountpoint with properties set to 0777 - and unison shows that as a difference which requires synchronization. How can I make unison…
einpoklum
  • 10,666
6
votes
1 answer

Stop Excel from changing file contents upon open

I use synchronization a lot on my machines. Excel changes the modification date right at the very moment it opens the file. Then, it changes the contents of the file (I guess to update the statistics embedded in the worksheet). Then, if user didn't…
Adam Ryczkowski
  • 832
  • 3
  • 9
  • 26
6
votes
1 answer

Does Unison socket mode support ipv6

I have been using Unison for quite some time now for synchronizing data between my machines, and I am very happy with it. Now I need to synchronize two new machines connected via ipv6, but they won't connect. One of the machines is running unison…
Nils Magne Lunde
  • 2,672
  • 1
  • 18
  • 14
6
votes
3 answers

Can Unison ignore files by their size?

The program rsync has the option --max-size=SIZE to prohibit transferring any file larger than SIZE. Does unison have a similar option?
Ole Tange
  • 5,099
5
votes
2 answers

Auto-resolving conflict with unison

I've set up a custom automated sync between 2 folders (in OSX) with unison with the following line: unison folder1 folder2 -batch -debug update+ Which worked fine until I encountered: Synchronization complete at 12:01:44 (0 item transferred, 1…
geotheory
  • 1,099
5
votes
1 answer

Synchronize two directories on linux pc

I need a distributed filesystem (or a synchronization tool) that is capable of keeping a directory synchronized across 4 pc. My requirements are: offline access (data must be available offline on each pc) preserve execution rights: some files are…
Gab
  • 151
5
votes
1 answer

How do you ignore all files but not subdirectories with Unison?

I want to sync the content of all subdirectories of a given root but only a few files in the root itself. To do so I would like to ignore all files using the ignore directive (keeping all subdirectories) and re-adding the few files I want to keep…
soriak
  • 221
1
2 3 4 5