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

53 questions
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
  • 829
  • 2
  • 12
  • 26
0
votes
2 answers

Why unison does not run in cronjob?

I want two way data sync between two CentOS based servers, so I installed Unison on both of my CentOS servers. I made a script file on root which runs unison and works fine, and syncs the files, when I run it from terminal. When I put that script in…
Mujtaba Haider
  • 131
  • 1
  • 7
0
votes
1 answer

using unison options in shell script?

I'm new to unison, and am trying to use its options in a simple shell script, but they seem to be ignored when the script is executed, causing no changes to be synced between the two servers. My shell script: #!/bin/bash # set paths /…
Elijah Paul
  • 557
  • 1
  • 8
  • 19
0
votes
2 answers

Load Balancing + Folder sync

i've 2 servers. Server A : contains mysql apache nginx Server B : contains apache memcached rsync cron ( each 3 mins ) that pulls the /var/www/ content and update its own I'm using: nginx of Server A to load balance the http requests. (And…
0
votes
1 answer

unison over ssh with white spaces in directories

I want to do something like this unison 192.168.1.1:/data/ /data/server_backup There is a space in the source directory. Is there some way I can do this with out using "\"
proy
  • 1,229
  • 10
  • 10
0
votes
1 answer

How i can use unison to sync. files of folder with the latest modification time?

I have to handle collisions (someone/something modified both files - How i can merge changes or just overwrite older version). In other word I want to sync folders with the latest modification time of its file Example :- folder_1/file.txt changed…
Eng Al-Rawabdeh
  • 39
  • 1
  • 10
0
votes
0 answers

Is there way to have some dconf settings stay local to the machine, while others are synced?

Situation I’m using Linux Mint, and am syncing my profile between two machines, using unison-gtk. Those machines have some key differences. One of them being that it’s a laptop, that should go to standby after 15 minutes, while the other one is a…
0
votes
1 answer

How do I set up Unison to open the meld GUI when I choose to merge in the Unison GUI

I am using the Unison GUI in Fedora. What should I add to my profile to set up "meld" as my merge-tool? I would like to have a similar user experience as in Git Gui, when I add meld as my mergetool. I would like to see three columns: left local,…
Jakob
  • 101
  • 1
1 2 3
4