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
1
vote
1 answer

Bash: echo a variable containing program output, to a file

When I execute unison tours 2> /dev/null | grep -A 2 '<-?->' on a bash prompt, I get the exact output i'm looking for: *changed <-?-> changed Future Tours/File Clash Test.docx local : changed file modified on 2013-06-05 at…
tcpman
  • 11
  • 2
1
vote
2 answers

Problems scripting Unison with Python

I am trying to make a simple script to automate and log synchronization via Unison. I am also using subprocess.Popen rather than the usual os.system call as it's deprecated. I've spent the past 2 days looking at docs and such trying to figure out…
1
vote
1 answer

Python Watchdog: Why is my subprocess called continuously?

I'm a novice with Python & I'm trying to automate synchronization with my home server with unison. I discovered watchdog & I'm trying to use it, but whenever I run "touch test.txt", the script continuously launches new unison processes. Since the…
1
vote
1 answer

unison sync files in directory but not folders

How can i tell unison given a sync path /home/user/mydata to only sync /home/user/mydata/file.txt /home/user/mydata/data.txt but not /home/user/mydata/subfolder I've simplified the question to this example but is there a way to tell it to sync only…
user391986
  • 29,536
  • 39
  • 126
  • 205
0
votes
3 answers

What is the best utility/library/strategy with Python to copy files across multiple computers?

I have data across several computers stored in folders. Many of the folders contain 40-100 G of files of size from 500 K to 125 MB. There are some 4 TB of files which I need to archive, and build a unfied meta data system depending on meta data…
ramdaz
  • 1,761
  • 1
  • 20
  • 43
0
votes
1 answer

How do you merge two conflicting files with Unison

I am having two nfs servers across which I am trying to sync files. I have the unison profile sync.prf this way. root = /home/ubuntu/nfs # shared directory on server1 root = ssh://ubuntu@XX.XX.XX.XX//home/ubuntu/nfs …
shihack
  • 57
  • 7
0
votes
1 answer

Unison: Ignore directory by name in all paths by using command line

I'm currently using unison for syncing local files with my cloud. Therefore I have set up a batch file which contains all options I need. "K:\unison\unison 2.48.4 text.exe" -batch -repeat 1200 -fastcheck true -log=false D:\localsync Z:\cloudsync In…
bear87
  • 83
  • 1
  • 11
0
votes
1 answer

Linux Unison: ignore all except multiple files

I want to synchronize two computers that are similar and update just a few files. Therefore I would like to perform a Unison and ignore everything except a list of files in different paths. Something like: # /usr/bin/unison-gtk /home/…
0
votes
1 answer

How i can use unison to sync. file of folders with the latest modification time?

How i can use unison to sync folders with the latest modification time of its file Example :- folder_1/file.txt changed at 12:30 folder_2/file.txt changed at 12:35 i wanna execute ./unison to give me the following result :- update file with regards…
Eng Al-Rawabdeh
  • 15
  • 1
  • 11
0
votes
1 answer

Unison creating different archives even when using same version

I have Unison 2.40.63 on both Windows and RHEL, all configs are working fine except when I try to run it first time it gives Fatal error: Internal error: New archives are not identical. Retaining original archives. Please run Unison again…
Utsav Mangal
  • 47
  • 1
  • 9
0
votes
1 answer

Unison / Rsync; mirror directories with sftp upload user

I know there are hundreds of questions about this topic. But I never found a clear example about it. I created two users one is the developer and the other the sftp upload user. The sftp upload user should be able to upload files and folders. Those…
josias
  • 1,326
  • 1
  • 12
  • 39
0
votes
1 answer

How do I bind a folder from a docker container to Windows?

High High, I have a very specific problem here & 3 days of searching hasn't helped. I have a docker file running my (enviroment) so to speak, currently it sets the container up, downloads the repo from git and cd's (WORKDIR) into said folder. It…
desupink
  • 11
  • 2
0
votes
1 answer

unison force option not recognized

I'm trying to do a one way synchronize (ie mirroring) of a local directory with a remote one on an accessible ssh server using unison and the option "-force" however the command is not recognized: $ unison -force /home/localuser/test_sync…
sarah.ferguson
  • 3,167
  • 2
  • 23
  • 31
0
votes
2 answers

Star topology in Unison with selective bidirectional syncs?

Let's say I have a server where I'd like to keep my central Unison repository, and I have two machines with directories Documents and .config on each. I'd like to synchronise Documents and .config to server but only Documents should be synchronised…
ardabro
  • 1,907
  • 16
  • 31
0
votes
1 answer

how to solve Unison 2.48\n" but received "grunt-cli: The grunt command line interface (v1.2.0)

I use docker and unison. I follow step by step in https://www.mgt-commerce.com/documentation/mgt-development-mac-file-synchronization. I am forget to run file synchronisation before I run grunt on my project use SSH. after I run grunt on my ssh…
Roy Wahyu
  • 1
  • 1