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
2
votes
0 answers

Unison fails because it cannot set time stamp

Trying to sync from a mac to a linux machine, I get multiple failures with a message of the following type: 100% 00:00 ETAFailed [www/sandbox/my-vue-buefy-project/node_modules/spdy-transport/lib/spdy-transport/protocol/spdy]: Failed to set…
2
votes
0 answers

Can not remove the file during unison sync

I have setup unison between Mac and Linux (both version 2.48.4) and sync-ing files is just fine. The problem is when I try to remove a file in one location, the file is not removed in the other location. Rather than that, the file is re-created in…
jaeyong
  • 8,951
  • 14
  • 50
  • 63
2
votes
2 answers

Can't find .unison directory on Mac OSX Sierra

I installed Unison via MacPorts on Mac OSX Sierra. I've read some tutorials online, and now want to write my own profile to set up the synchronization. Sadly, I can't find the .unison folder where the profiles are stored in.
schmolmp
  • 53
  • 5
2
votes
1 answer

Executing a command in unison before its closes the ssh connection

Unison is a file-synchronization tool that works over ssh. It accepts configurations in profile (.prf) files. I use an alias unison my-pref.prf && ssh sameuser@sameserver.fr 'cat toto' Hence I have to type my password twice. Do you know any way to…
Clément
  • 2,358
  • 28
  • 32
2
votes
1 answer

How to kill port forwarding once you have have finished using it

In order to sync my home and work file systems I need to go via an intermediary computer and use port forwarding. Let us call the home computer A, the intermediate one B and the work computer C. From the command line I do this ssh -N -f -L 2025:C:22…
Simd
  • 19,447
  • 42
  • 136
  • 271
2
votes
1 answer

How to sync when you can't connect directly to the remote computer

I have my home computer A and a work computer C that I want to synchronise using unison. In the middle is a work computer B. A can communicate with B and B can communicate with C directly but A and C can't directly connect to each other. In fact…
Simd
  • 19,447
  • 42
  • 136
  • 271
2
votes
1 answer

unison across shared drive on windows

I have a shared drive at \192.168.1.110 My unison is setup to copy from C:\mydata to \\192.168.1.110\mydata I can access \192.168.1.110\mydata however when I try from the command prompt unison tells me 'Logon failure: unknown user name or bad…
user391986
  • 29,536
  • 39
  • 126
  • 205
1
vote
1 answer

How to let unison output the results of comparing replicas but not synchronize them

I have a question about the file synchronizer, unison. Is there a way to let unison compare two replicas and output the difference (to the standard output or a file) but not execute any updates? I could do this by just hitting / (skip) for each…
norio
  • 3,652
  • 3
  • 25
  • 33
1
vote
1 answer

Compile unison 2.48.4 build with OCaml version 4.08.1 on Manjaro

I need a specific unison version compilied with a specific OCaml version to work together with the unison package on Ubuntu Server 20.04 LTS. I need unison 2.48.4 build with OCaml version 4.08.1. The package in AUR seems to be build with another…
exaveal
  • 11
  • 1
1
vote
1 answer

Unison: sync only in one direction ...option selected in profile

I'm effectively asking this question: Unison: sync only in one direction but I'd like to apply the accepted answer to a profile script. Can I do that? unison /src/dir /dest/dir -force /src/dir -nodeletion /dest/dir Cheers!
bitrat
  • 25
  • 9
1
vote
1 answer

On Mac Big Sur, how do i build unison with a specific version of ocaml?

I'm using Mac OS Big Sur (11.5.6). I have installed the following version of ocaml (via opam) ... $ ocaml --version The OCaml toplevel, version 4.08.1 However, when I build unison via homebrew, it seems to use a different version of ocaml ... $…
Dave
  • 15,639
  • 133
  • 442
  • 830
1
vote
1 answer

problem with getting unison-gtk2 to run on mac

Probably I'm not doing this right, but I'm trying to get the gui-version of unison to run on my mac (Big Sur 11.4), but when I download binary release (https://github.com/bcpierce00/unison/releases) and run unison-gtk2, it says Warning: DISPLAY not…
mchlmchl
  • 23
  • 2
1
vote
0 answers

Unison star topology: assume no changes on a passive node

I have been using Unison in a star topology to synchronize my two machines through a server. Now I'm trying to replace the server with storage on rsync.net. However, synchronization requires checking the access times in both replicas, which takes…
pkarnakov
  • 123
  • 1
  • 7
1
vote
1 answer

run unison in bash script

Hi when I run a command on terminal like that unison dir1 dir2 -ignore 'Regex dir3' -batch -force dir1 -confirmbigdel=false it runs normally. But when I try to run it in a bash script it like that a="-ignore 'Regex dir3'" unison dir1 dir2 "$a"…
ibrahim
  • 3,254
  • 7
  • 42
  • 56
1
vote
0 answers

Why Unison doesn't work in described situation?

In my project i have structure like this one: I am using unison repeat=watch to sync folders A and B. It's working well when i put something to dir A or B, but when i place a file in folder C it doesnt work. File is visible in B, but not in A. C is…
dkruchala
  • 23
  • 1
  • 8