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

51 questions
1
vote
1 answer

After cloud server rebuild, why does SSH give me an ssh_exchange_identification error?

We recently had to rebuild one of our cloud servers (we use Rackspace). All servers are almost identical, and a snapshot of another server was used. Once live again, I allowed a cron job to run which syncs a couple of files outside source control…
Leonard Challis
  • 23
  • 3
  • 12
  • 26
1
vote
0 answers

Bash Script that connects to VPN server via openvpn, runs a program, and then disconnects from openvpn server

The operating system I am using is Ubuntu Server 10. I've been trying to cobble together a way to connect to a vpn server via openvpn using command line, run a unison profile, and then disconnect from the vpn connection - all from a bash script.…
Alexo
  • 11
  • 1
1
vote
1 answer

How do I ignore errors with Unison?

I'm trying to synchronize two directories using Unison, however if it encounters a file with an error, then it skips the entire directory! I don't believe it should skip the whole directory, and instead should just skip that file. I'm OK with that.…
Chloe
  • 1,094
  • 4
  • 16
  • 34
1
vote
1 answer

Is there anything more than `fastcheck` to speed up Unison?

I routinely use Unison to sync users' home directories between workstations where the user is expected to work. Unfortunately, as the firm grows, the Unison become slower and slower in determining what files have changed. The time taken by actual…
Adam Ryczkowski
  • 690
  • 1
  • 9
  • 29
1
vote
1 answer

How do I setup unison to sync a folder one way

I have a 1tb NAS that has a 1tb usb external hard attached I have prepared the file system on the usb disk and mounted it I want to 100% sync my data from my nas to the usb disk - but I want it to be incremental and only have the NAS as the 'master'…
Rob
  • 215
  • 3
  • 10
1
vote
2 answers

unison / rsync getting copies of changed files

So the place where I'm working at has a nifty little Red Hat Enterprise server and a tape backup system that they want me to get working backing up the large amounts of video content and resources produced by the company. The desired situation would…
Russell C
  • 115
  • 1
  • 1
  • 8
1
vote
0 answers

Unison not syncing

I am using Unison to sync files between multiple servers. The exact command that I am running is: /bin/unison-text-2.40 /etc/asterisk/dynamic_configs ssh://filesync/opt/dynamic_configs -batch -confirmbigdel=false -force newer -times I have it set…
Dovid Bender
  • 397
  • 1
  • 6
  • 16
0
votes
1 answer

Server cluster setup using UNISON to sync files bi-directionally line/star/fully connected?

I appreciate that I'm asking multiple questions on the same topic, but they are all related to the same purpose. Working a horizontal scaling cluster setup, and trying to setup unison to sync "var/www/html" for HA. To sync between 2 servers is easy…
Mecanik
  • 101
  • 2
0
votes
2 answers

unison set owner of files

I'm copying files from my workstation to a dev sandbox, locally I don't have the www-data user, which is needed by my web server. Is there a way to set up an user_id for files synced by unison?
astropanic
  • 297
  • 2
  • 5
  • 18
0
votes
2 answers

Synchronization over ssh with restricted access to the server file system

I want to synchronize (both directions) a certain folder between a server (S) and a local machine (L). On both S and L, I have the same system (Ubuntu) and a user jan, with sudo privileges (i.e. in admin group). The SSH access to S is possible only…
galapah
  • 101
  • 1
0
votes
1 answer

Restrict unison to work only on certain folder (on the remote server)

Considering the scenario where Server1 wants to keep folder /x synchronized between itself and Server2. So apparently one have to add a new (SSH) user to Server2 allowing for this. So we result in a command similar to: $ unison -batch /x…
Wizche
  • 101
  • 1
0
votes
1 answer

Unison sync getting copy of replaced files

I'm facing very serious issue. I have configured unison for synchronising file among servers. It takes copy of a file from server-1 and replace or copy file to other servers. I have added a folder directly on server-2 and server-1(base server) had…
0
votes
1 answer

unison: -force only on conflict

According to Unison Manual, using -force : Including the preference -force root causes Unison to resolve all differences (even non-conflicting changes) in favor of root. However, I want to force it only in conflicting changes, how can I…
lepe
  • 468
  • 1
  • 6
  • 23
0
votes
1 answer

How can I make unison stop writing itself to root root when sshing from server to server?

I am using this command: sudo unison /opt/bitnami/apache2/htdocs/test/wp-content/uploads/ ssh://xxxx@wxxxx.cloudapp.net:7775//opt/bitnami/apache2/htdocs/test/wp-content/uploads -owner -group upon doing so it changes this file in my .unison file…
0
votes
1 answer

unison as non-root user

I want to use unison to sync the /home directories between two EL6 boxes. Most writeups assume that unison is run as root, and can ssh between the two boxes as root. However, we have disabled root logins in both /etc/passwd, as well as…
user52874
  • 819
  • 2
  • 10
  • 25