Unison Manual
Unison Manual
Version 2.53.7
Overview
Features:
* Unison works across platforms, allowing you to synchronize a
Windows laptop with a Unix server, for example.
* 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.
* Unlike simple mirroring or backup utilities, Unison can deal with
updates to both replicas of a distributed directory structure.
Updates that do not conflict can be propagated automatically.
Conflicting updates are detected and displayed.
* 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. Transfers of
small updates to large files are optimized using a compression
protocol similar to rsync.
* Unison has a clear and precise specification, described below.
* 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 is free; full source code is available under the GNU Public
License.
Preface
People
Obtaining Unison
Source code
https://github.com/bcpierce00/unison
Binaries
https://github.com/bcpierce00/unison/wiki
Many people use and contribute to Unison. This community has two main
homes.
Mailinglists
https://github.com/bcpierce00/unison/wiki/Mailing-Lists
Reporting Bugs
Bug reports and feature requests may be made after reading the
guidelines:
https://github.com/bcpierce00/unison/wiki/Reporting-Bugs-and-Feature
-Requests
Copying
Acknowledgements
Upgrading
Before upgrading, it is a good idea to run the old version one last
time, to make sure all your replicas are completely synchronized. A new
version of Unison will sometimes introduce a different format for the
archive files used to remember information about the previous state of
the replicas. In this case, the old archive will be ignored (not
deleted — if you roll back to the previous version of Unison, you will
find the old archives intact), which means that any differences between
the replicas will show up as conflicts that need to be resolved
manually.
After upgrading the archive, you are free to swap the Unison 2.52 or
newer executable to one compiled with a different version of OCaml. The
archive file is no longer dependent on the compiler version.
Version interoperability
Tutorial
Preliminaries
The textual interface is more convenient for running from scripts and
works on dumb terminals; the graphical interface is better for most
interactive use. For this tutorial, you can use either. If you are
running Unison from the command line, just typing unison will select
either the text or the graphical interface, depending on which has been
selected as default when the executable you are running was built. You
can force the text interface even if graphical is the default by adding
-ui text. The other command-line arguments to both versions are
identical.
The graphical version can also be run directly by clicking on its icon.
For this tutorial, we assume that you’re starting it from the command
line.
Local Usage
Let’s get the client machine set up first and see how to synchronize
two directories on a single machine.
Now try synchronizing a.tmp and b.tmp. (Since they are identical,
synchronizing them won’t propagate any changes, but Unison will
remember the current state of both directories so that it will be able
to tell next time what has changed.) Type:
unison a.tmp b.tmp
(You may need to add -ui text, depending how your unison binary was
built.)
Textual Interface:
* You should see a message notifying you that all the files are
actually equal and then get returned to the command line.
Graphical Interface:
* You should get a big empty window with a message at the bottom
notifying you that all files are identical. Choose the Exit item
from the File menu to get back to the command line.
This time, the user interface will display only the files that have
changed. If a file has been modified in just one replica, then it will
be displayed with an arrow indicating the direction that the change
needs to be propagated. For example,
<--- new file c [f]
indicates that the file c has been modified only in the second replica,
and that the default action is therefore to propagate the new version
to the first replica. To follow Unison’s recommendation, press the “f”
at the prompt.
If both replicas are modified and their contents are different, then
the changes are in conflict: <-?-> is displayed to indicate that Unison
needs guidance on which replica should override the other.
new file <-?-> new file d/h []
If both replicas have been modified but their new contents are the same
(as with the file b), then no propagation is necessary and nothing is
shown. Unison simply notes that the file is up to date.
Textual Interface:
* The status of each modified file is displayed, in turn. When the
copies of a file in the two replicas are not identical, the user
interface will ask for instructions as to how to propagate the
change. If some default action is indicated (by an arrow), you can
simply press Return to go on to the next changed file. If you want
to do something different with this file, press “<” or “>” to force
the change to be propagated from right to left or from left to
right, or else press “/” to skip this file and leave both replicas
alone. When it reaches the end of the list of modified files,
Unison will ask you one more time whether it should proceed with
the updates that have been selected.
When Unison stops to wait for input from the user, pressing “?”
will always give a list of possible responses and their meanings.
Graphical Interface:
* The main window shows all the files that have been modified in
either a.tmp or b.tmp. To override a default action (or to select
an action in the case when there is no default), first select the
file, either by clicking on its name or by using the up- and
down-arrow keys. Then press either the left-arrow or “<” key (to
cause the version in b.tmp to propagate to a.tmp) or the
right-arrow or “>” key (which makes the a.tmp version override
b.tmp).
Every keyboard command can also be invoked from the menus at the
top of the user interface. (Conversely, each menu item is annotated
with its keyboard equivalent, if it has one.)
When you are satisfied with the directions for the propagation of
changes as shown in the main window, click the “Go” button to set
them in motion. A check sign will be displayed next to each
filename when the file has been dealt with.
Remote Usage
Next, we’ll get Unison set up to synchronize replicas on two different
machines.
NB: Unison has not been designed to run with elevated privileges (e.g.
setuid), and it has not been audited for that environment. Therefore
Unison should be run with the userid of the owner of the files to be
synchronized, and should never be run setuid or similar. (Problems
encountered when running setuid etc. must be reproduced without setuid
before being reported as bugs.)
Decide which of these you want to try, and continue with the section
“Remote Shell Method” or the section “Socket Method” , as appropriate.
Running ssh requires some coordination between the client and server
machines to establish that the client is allowed to invoke commands on
the server; please refer to the ssh documentation for information on
how to set this up.
First, test that we can invoke Unison on the server from the client.
Typing
ssh remotehostname unison -version
Test that the local unison client can start and connect to the remote
server. Type
unison -testServer a.tmp ssh://remotehostname/a.tmp
The result should be that the entire directory a.tmp is propagated from
the client to your home directory on the server.
After finishing the first synchronization, change a few files and try
synchronizing again. You should see similar results as in the local
case.
If your user name on the server is not the same as on the client, you
need to specify it on the command line:
unison a.tmp ssh://username@remotehostname/a.tmp
Notes:
* If you want to put a.tmp some place other than your home directory
on the remote host, you can give an absolute path for it by adding
an extra slash between remotehostname and the beginning of the
path:
unison a.tmp ssh://remotehostname//absolute/path/to/a.tmp
* You can give an explicit path for the unison executable on the
server by using the command-line option "-servercmd
/full/path/name/of/unison" or adding
"servercmd=/full/path/name/of/unison" to your profile (see the
section “Profiles” ). Similarly, you can specify an explicit path
for the ssh program using the "-sshcmd" option. Extra arguments can
be passed to ssh by setting the -sshargs preference.
* By leveraging "-sshcmd" and "-sshargs", you can effectively use any
remote shell program, not just ssh; just remember that the roots
are still specified with ssh as the protocol, that is, they have to
start with "ssh://".
Socket Method
To run Unison over a socket connection, you must start a Unison daemon
process on the server. This process runs continuously, waiting for
connections over a given socket from client machines running Unison and
processing their requests in turn.
Since the socket method is not used by many people, its functionality
is rather limited. For example, the server can only deal with one
client at a time.
TCP Sockets
Warning: The TCP socket method is insecure: not only are the texts
of your changes transmitted over the network in unprotected form, it
is also possible for anyone in the world to connect to the server
process and read out the contents of your filesystem! (Of course, to
do this they must understand the protocol that Unison uses to
communicate between client and server, but all they need for this is
a copy of the Unison sources.) The socket method is provided only
for expert users with specific needs; everyone else should use the
ssh method.
on the server machine, where NNNN is the TCP port number that the
daemon should listen on for connections from clients. (NNNN can be any
large number that is not being used by some other program; if NNNN is
already in use, Unison will exit with an error message.)
To start the daemon for connections over a Unix domain socket, type
unison -socket PPPP
where PPPP is the path to a Unix socket that the daemon should open for
connections from clients. (PPPP can be any absolute or relative path
the server process has access to but it must not exist yet; the socket
is created at that path when the daemon process is started.) You are
responsible for securing access to the socket path. For example, this
can be done by controlling the permissions of socket’s parent
directory, or ensuring a restrictive umask value when starting Unison.
Note that Unix domain sockets are local sockets (they exist in the
filesystem namespace). One could use Unixs socket remotely, by
forwarding access to the socket by other means, for example by using
spiped secure pipe daemon.
Once you are comfortable with the basic operation of Unison, you may
find yourself wanting to use it regularly to synchronize your commonly
used files. There are several possible ways of going about this:
1. Synchronize your whole home directory, using the Ignore facility
(see the section “Ignoring Paths” ) to avoid synchronizing
temporary files and things that only belong on one host.
2. Create a subdirectory called shared (or current, or whatever) in
your home directory on each host, and put all the files you want to
synchronize into this directory.
3. Create a subdirectory called shared (or current, or whatever) in
your home directory on each host, and put links to all the files
you want to synchronize into this directory. Use the follow
preference (see the section “Symbolic Links” ) to make Unison treat
these links as transparent.
4. Make your home directory the root of the synchronization, but tell
Unison to synchronize only some of the files and subdirectories
within it on any given run. This can be accomplished by using the
-path switch on the command line:
unison /home/username ssh://remotehost//home/username -path shared
These -path arguments can also be put in your preference file. See
the section “Preferences” for an example.
Most people find that they only need to maintain a profile (or
profiles) on one of the hosts that they synchronize, since Unison is
always initiated from this host. (For example, if you’re synchronizing
a laptop with a fileserver, you’ll probably always run Unison on the
laptop.) This is a bit different from the usual situation with
asymmetric mirroring programs like rdist, where the mirroring operation
typically needs to be initiated from the machine with the most recent
changes. the section “Profiles” covers the syntax of Unison profiles,
together with some sample profiles.
If you use Unison regularly, you should subscribe to one of the mailing
lists, to receive announcements of new versions. See the section
“Obtaining Unison” .
Basic Concepts
Roots
If the remote server is already running (in the socket mode), then the
syntax
socket://remotehost:portnum//absolute/path/of/root
socket://remotehost:portnum/relative/path/of/root
socket://[IPv6literal]:portnum/path
is used to specify the hostname and the port that the client Unison
should use to contact it. Syntax
socket://{path/of/socket}//absolute/path/of/root
socket://{path/of/socket}/relative/path/of/root
is used to specify the Unix domain socket the client Unison should use
to contact the server.
The syntax for roots is based on that of URIs (described in RFC 2396).
The full grammar is:
replica ::= [protocol:]//[user@][host][:port][/path]
| path
When path is given without any protocol prefix, the protocol is assumed
to be file:. Under Windows, it is possible to synchronize with a remote
directory using the file: protocol over the Windows Network
Neighborhood. For example,
unison foo //host/drive/bar
Paths
The empty path (i.e., the empty sequence of names) denotes the whole
replica. Unison displays the empty path as “[root].”
We say that a path is updated (in some replica) if its current contents
are different from its contents the last time it was successfully
synchronized. Note that whether a path is updated has nothing to do
with its last modification time—Unison considers only the contents when
determining whether an update has occurred. This means that touching a
file without changing its contents will not be recognized as an update.
A file can even be changed several times and then changed back to its
original contents; as long as Unison is only run at the end of this
process, no update will be recognized.
What is a Conflict?
Reconciliation
Invariants
Unison is careful to protect both its internal state and the state of
the replicas at every point in this process. Specifically, the
following guarantees are enforced:
* At every moment, each path in each replica has either (1) its
original contents (i.e., no change at all has been made to this
path), or (2) its correct final contents (i.e., the value that the
user expected to be propagated from the other replica).
* At every moment, the information stored on disk about Unison’s
private state can be either (1) unchanged, or (2) updated to
reflect those paths that have been successfully synchronized.
Changes to the ignore patterns from the user interface (e.g., using the
‘i’ key) are immediately reflected in the current profile.
Reference Guide
Running Unison
The archive file for each replica is found in the .unison directory on
that replica’s host. Profiles (described below) are always taken from
the .unison directory on the client host.
Archive Files
The function that finds the canonical hostname of the local host (which
is used, for example, in calculating the name of the archive file used
to remember which files have been synchronized) normally uses the
gethostname operating system call. However, if the environment variable
UNISONLOCALHOSTNAME is set, its value will be used instead. This makes
it easier to use Unison in situations where a machine’s name changes
frequently (e.g., because it is a laptop and gets moved around a lot).
When calculating the name of the archive files for a given pair of
roots, Unison replaces any root that matches the left-hand side of any
rootalias rule by the corresponding right-hand side.
So, if you need to relocate a root on one of the hosts, you can add a
rule of the form:
rootalias = //new-hostname//new-path -> //old-hostname/old-path
Preferences
Here are all the preferences supported by Unison. This list can be
obtained by typing unison -help.
Basic options:
General:
-doc xxx show documentation ('-doc topics' lists topics)
-version print version and exit
What to sync:
-group synchronize group attributes
-ignore xxx add a pattern to the ignore list
-ignorenot xxx add a pattern to the ignorenot list
-nocreation xxx prevent file creations on one replica
-nodeletion xxx prevent file deletions on one replica
-noupdate xxx prevent file updates and deletions on one replica
-owner synchronize owner
-path xxx path to synchronize
-perms n part of the permissions which is synchronized
-root xxx root of a replica (should be used exactly twice)
-times synchronize modification times
How to sync:
-batch batch mode: ask no questions at all
Advanced options:
Fine-tune sync:
-acl synchronize ACLs
-atomic xxx add a pattern to the atomic list
-follow xxx add a pattern to the follow list
-force xxx force changes from this replica to the other
-forcepartial xxx add a pattern to the forcepartial list
-ignorecase xxx identify upper/lowercase filenames (true/false/default)
-immutable xxx add a pattern to the immutable list
-immutablenot xxx add a pattern to the immutablenot list
-links xxx allow the synchronization of symbolic links
(true/false/default)
-merge xxx add a pattern to the merge list
-nocreationpartial xxx add a pattern to the nocreationpartial list
-nodeletionpartial xxx add a pattern to the nodeletionpartial list
-noupdatepartial xxx add a pattern to the noupdatepartial list
-prefer xxx choose this replica's version for conflicting changes
-preferpartial xxx add a pattern to the preferpartial list
-rsrc xxx synchronize resource forks (true/false/default)
-xattrignore xxx add a pattern to the xattrignore list
-xattrignorenot xxx add a pattern to the xattrignorenot list
-xattrs synchronize extended attributes (xattrs)
How to sync:
-backup xxx add a pattern to the backup list
-backupcurr xxx add a pattern to the backupcurr list
-backupcurrnot xxx add a pattern to the backupcurrnot list
-backupdir xxx directory for storing centralized backups
-backuploc xxx where backups are stored ('local' or 'central')
-backupnot xxx add a pattern to the backupnot list
-backupprefix xxx prefix for the names of backup files
-backups (deprecated) keep backup copies of all files (see also
'backup')
-backupsuffix xxx a suffix to be added to names of backup files
-confirmbigdel ask about whole-replica (or path) deletes (default true)
-confirmmerge ask for confirmation before committing results of a merge
-copyonconflict keep copies of conflicting files
-dontchmod when set, never use the chmod system call
-fastcheck xxx do fast update detection (true/false/default)
-fat use appropriate options for FAT filesystems
-ignoreinodenumbers ignore inode number changes when detecting updates
-maxbackups n number of backed up versions of a file
-numericids don't map uid/gid values by user/group names
-sortbysize list changed files by size, not name
-sortfirst xxx add a pattern to the sortfirst list
-sortlast xxx add a pattern to the sortlast list
-sortnewfirst list new before changed files
Remote connections:
-addversionno add version number to name of unison on server
-clientHostName xxx set host name of client
-halfduplex (deprecated) force half-duplex communication with the
server
-killserver kill server when done (even when using sockets)
-listen xxx listen on this name or addr in server socket mode (can
repeat)
-rsync activate the rsync transfer mode (default true)
-servercmd xxx name of unison executable on remote server
-socket xxx act as a server on a socket
-sshargs xxx other arguments (if any) for remote shell command
-sshcmd xxx path to the ssh executable
-stream (deprecated) use a streaming protocol for transferring
file contents (default true)
-testserver exit immediately after the connection to the server
-xferbycopying optimize transfers using local copies (default true)
Archive management:
-ignorearchives ignore existing archive files
Other:
-addprefsto xxx file to add new prefs to
-contactquietly suppress the 'contacting server' message during startup
-copymax n (deprecated) maximum number of simultaneous copyprog
transfers
-copyprog xxx (deprecated) external program for copying large files
-copyprogrest xxx (deprecated) variant of copyprog for resuming partial
transfers
-copythreshold n (deprecated) use copyprog on files bigger than this (if
>=0, in Kb)
-diff xxx set command for showing differences between files
-ignorelocks ignore locks left over from previous run (dangerous!)
-include xxx include a profile's preferences
-key xxx define a keyboard shortcut for this profile (in some UIs)
-label xxx provide a descriptive string label for this profile
-log record actions in logfile (default true)
-logfile xxx logfile name
-maxerrors n maximum number of errors before a directory transfer is
aborted
-maxsizethreshold n prevent transfer of files bigger than this (if >=0, in
Kb)
-maxthreads n maximum number of simultaneous file transfers
-mountpoint xxx abort if this path does not exist
-rootalias xxx register alias for canonical root names
-showarchive show 'true names' (for rootalias) of roots and archive
-source xxx include a file's preferences
-ui xxx select UI ('text' or 'graphic'); command-line only
-unicode xxx assume Unicode encoding in case insensitive mode
-watch when set, use a file watcher process to detect changes
Expert options:
-debug xxx debug module xxx ('all' -> everything, 'verbose' -> more)
-dumparchives dump contents of archives just after loading
-fastercheckUNSAFE skip computing fingerprints for new files (experts only!)
-selftest run internal tests and exit
Here, in more detail, is what they do. Many are discussed in greater
detail in other sections of the manual.
acl
When this flag is set to true, the ACLs of files and directories
are synchronized. The type of ACLs depends on the platform and
filesystem support. On Unix-like platforms it can be NFSv4 ACLs,
for example.
addprefsto xxx
By default, new preferences added by Unison (e.g., new ignore
clauses) will be appended to whatever preference file Unison was
told to load at the beginning of the run. Setting the preference
addprefsto filename makes Unison add new preferences to the file
named filename instead.
addversionno
When this flag is set to true, Unison will use
unison-currentmajorversionnumber instead of just unison as the
remote server command (note that the minor version number is
dropped – e.g., unison-2.51). This allows multiple binaries for
different versions of unison to coexist conveniently on the same
server: whichever version is run on the client, the same version
will be selected on the server.
atomic xxx
This preference specifies paths for directories whose contents
will be considered as a group rather than individually when they
are both modified. The backups are also made atomically in this
case. The option backupcurr however has no effect on atomic
directories.
auto
When set to true, this flag causes the user interface to skip
asking for confirmations on non-conflicting changes. (More
precisely, when the user interface is done setting the
propagation direction for one entry and is about to move to the
next, it will skip over all non-conflicting entries and go
directly to the next conflict.)
backup xxx
Including the preference -backup pathspec causes Unison to keep
backup files for each path that matches pathspec; directories
(nor their permissions or any other metadata) are not backed up.
These backup files are kept in the directory specified by the
backuplocation preference. The backups are named according to
the backupprefix and backupsuffix preferences. The number of
versions that are kept is determined by the maxbackups
preference.
backupcurr xxx
Including the preference -backupcurr pathspec causes Unison to
keep a backup of the current version of every file matching
pathspec. This file will be saved as a backup with version
number 000. Such backups can be used as inputs to external
merging programs, for instance. See the documentation for the
merge preference. For more details, see the section “Merging
Conflicting Versions” .
backupcurrnot xxx
Exceptions to backupcurr, like the ignorenot preference.
backupdir xxx
If this preference is set, Unison will use it as the name of the
directory used to store backup files specified by the backup
preference, when backuplocation is set to central. It is checked
after the UNISONBACKUPDIR environment variable.
backuploc xxx
This preference determines whether backups should be kept
locally, near the original files, or in a central directory
specified by the backupdir preference. If set to local, backups
will be kept in the same directory as the original files, and if
set to central, backupdir will be used instead.
backupnot xxx
The values of this preference specify paths or individual files
or regular expressions that should not be backed up, even if the
backup preference selects them—i.e., it selectively overrides
backup.
backupprefix xxx
When a backup for a file NAME is created, it is stored in a
directory specified by backuplocation, in a file called
backupprefixNAMEbackupsuffix. backupprefix can include a
directory name (causing Unison to keep all backup files for a
given directory in a subdirectory with this name), and both
backupprefix and backupsuffix can contain the string $VERSION,
which will be replaced by the age of the backup (1 for the most
recent, 2 for the second most recent, and so on...). This
keyword is ignored if it appears in a directory name in the
prefix; if it does not appear anywhere in the prefix or the
suffix, it will be automatically placed at the beginning of the
suffix.
backups
(Deprecated) Setting this flag to true is equivalent to setting
backuplocation to local and backup to Name *.
backupsuffix xxx
See backupprefix for full documentation.
batch
When this is set to true, the user interface will ask no
questions at all. Non-conflicting changes will be propagated;
conflicts will be skipped.
clientHostName xxx
When specified, the host name of the client will not be guessed
and the provided host name will be used to find the archive.
color xxx
When set to true, this flag enables color output in text mode
user interface. When set to false, all color output is disabled.
Default is to enable color if the NO_COLOR environment variable
is not set.
confirmbigdel
When this is set to true, Unison will request an extra
confirmation if it appears that the entire replica has been
deleted, before propagating the change. If the batch flag is
also set, synchronization will be aborted. When the path
preference is used, the same confirmation will be requested for
top-level paths. (At the moment, this flag only affects the text
user interface.) See also the mountpoint preference.
confirmmerge
Setting this preference causes both the text and graphical
interfaces to ask the user if the results of a merge command may
be committed to the replica or not. Since the merge command
works on temporary files, the user can then cancel all the
effects of applying the merge if it turns out that the result is
not satisfactory. In batch-mode, this preference has no effect.
Default is false.
contactquietly
If this flag is set, Unison will skip displaying the ‘Contacting
server’ message (which some users find annoying) during startup.
copymax n
(Deprecated) A number indicating how many instances of the
external copying utility Unison is allowed to run simultaneously
(default to 1).
copyonconflict
When this flag is set, Unison will make a copy of files that
would otherwise be overwritten or deleted in case of conflicting
changes, and more generally whenever the default behavior is
overridden. This makes it possible to automatically resolve
conflicts in a fairly safe way when synchronizing continuously,
in combination with the -repeat watch and -prefer newer
preferences.
copyprog xxx
(Deprecated) A string giving the name of an external program
that can be used to copy large files efficiently (plus
command-line switches telling it to copy files in-place). The
default setting invokes rsync with appropriate options—most
users should not need to change it.
copyprogrest xxx
(Deprecated) A variant of copyprog that names an external
program that should be used to continue the transfer of a large
file that has already been partially transferred. Typically,
copyprogrest will just be copyprog with one extra option (e.g.,
--partial, for rsync). The default setting invokes rsync with
appropriate options—most users should not need to change it.
copythreshold n
(Deprecated) A number indicating above what filesize (in
kilobytes) Unison should use the external copying utility
specified by copyprog. Specifying 0 will cause all copies to use
the external program; a negative number will prevent any files
from using it. The default is -1. See the section “Making Unison
Faster on Large Files” for more information.
debug xxx
This preference is used to make Unison print various sorts of
information about what it is doing internally on the standard
error stream. It can be used many times, each time with the name
of a module for which debugging information should be printed.
Possible arguments for debug can be found by looking for calls
to Util.debug in the sources (using, e.g., grep). Setting -debug
all causes information from all modules to be printed (this mode
of usage is the first one to try, if you are trying to
understand something that Unison seems to be doing wrong);
-debug verbose turns on some additional debugging output from
some modules (e.g., it will show exactly what bytes are being
sent across the network).
diff xxx
This preference can be used to control the name and command-line
arguments of the system utility used to generate displays of
file differences. The default is ‘diff -u OLDER NEWER’. If the
value of this preference contains the substrings CURRENT1 and
CURRENT2, these will be replaced by the names of the files to be
diffed. If the value of this preference contains the substrings
NEWER and OLDER, these will be replaced by the names of files to
be diffed, NEWER being the most recently modified file of the
two. Without any of these substrings, the two filenames will be
appended to the command. In all cases, the filenames are
suitably quoted.
doc xxx
The command-line argument -doc secname causes unison to display
section secname of the manual on the standard output and then
exit. Use -doc all to display the whole manual, which includes
exactly the same information as the printed and HTML manuals,
modulo formatting. Use -doc topics to obtain a list of the names
of the various sections that can be printed.
dontchmod
By default, Unison uses the ’chmod’ system call to set the
permission bits of files after it has copied them. But in some
circumstances (and under some operating systems), the chmod call
always fails. Setting this preference completely prevents Unison
from ever calling chmod.
dumbtty
When set to true, this flag makes the text mode user interface
avoid trying to change any of the terminal settings. (Normally,
Unison puts the terminal in ‘raw mode’, so that it can do things
like overwriting the current line.) This is useful, for example,
when Unison runs in a shell inside of Emacs.
dumparchives
When this preference is set, Unison will create a file
unison.dump on each host, containing a text summary of the
archive, immediately after loading it.
fastcheck xxx
When this preference is set to true, Unison will use the
modification time and length of a file as a ‘pseudo inode
number’ when scanning replicas for updates, instead of reading
the full contents of every file. (This does not apply to the
very first run, when Unison will always scan all files
regardless of this switch). Under Windows, this may cause Unison
to miss propagating an update if the modification time and
length of the file are both unchanged by the update. However,
Unison will never overwrite such an update with a change from
the other replica, since it always does a safe check for updates
just before propagating a change. Thus, it is reasonable to use
this switch under Windows most of the time and occasionally run
Unison once with fastcheck set to false, if you are worried that
Unison may have overlooked an update. For backward
compatibility, yes, no, and default can be used in place of
true, false, and auto. See the section “Fast Update Detection”
for more information.
fastercheckUNSAFE
THIS FEATURE IS STILL EXPERIMENTAL AND SHOULD BE USED WITH
EXTREME CAUTION.
Most users should leave this flag off – the small time savings
of not fingerprinting new files is not worth the cost in terms
of safety. However, it can be very useful for power users with
huge replicas that are known to be already synchronized (e.g.,
because one replica is a newly created duplicate of the other,
or because they have previously been synchronized with Unison
but Unison’s archives need to be rebuilt). In such situations,
it is recommended that this flag be set only for the initial run
of Unison, so that new archives can be created quickly, and then
turned off for normal use.
fat
When this is set to true, Unison will use appropriate options to
synchronize efficiently and without error a replica located on a
FAT filesystem on a non-Windows machine: do not synchronize
permissions (perms = 0); never use chmod (dontchmod = true);
treat filenames as case insensitive (ignorecase = true); do not
attempt to synchronize symbolic links (links = false); ignore
inode number changes when detecting updates (ignoreinodenumbers
= true). Any of these change can be overridden by explicitly
setting the corresponding preference in the profile.
follow xxx
Including the preference -follow pathspec causes Unison to treat
symbolic links matching pathspec as ‘invisible’ and behave as if
the object pointed to by the link had appeared literally at this
position in the replica. See the section “Symbolic Links” for
more details. The syntax of pathspec is described in the section
“Path Specification” .
force xxx
Including the preference -force root causes Unison to resolve
all differences (even non-conflicting changes) in favor of root.
This effectively changes Unison from a synchronizer into a
mirroring utility.
You can also specify -force newer (or -force older) to force
Unison to choose the file with the later (earlier) modtime. In
this case, the -times preference must also be enabled. If
modtimes are equal in both replicas when using newer or older
then this preference will have no effect (changes will be synced
as if without this preference or remain unsynced in case of a
conflict).
This preference should be used only if you are sure you know
what you are doing!
forcepartial xxx
Including the preference forcepartial = PATHSPEC -> root causes
Unison to resolve all differences (even non-conflicting changes)
in favor of root for the files in PATHSPEC (see the section
“Path Specification” for more information). This effectively
changes Unison from a synchronizer into a mirroring utility.
This preference should be used only if you are sure you know
what you are doing!
group
When this flag is set to true, the group attributes of the files
are synchronized. Whether the group names or the group
identifiers are synchronized depends on the preference numerids.
halfduplex
(Deprecated) When this flag is set to true, Unison network
communication is forced to be half duplex (the client and the
server never simultaneously emit data). If you experience
unstabilities with your network link, this may help.
height n
Used to set the height (in lines) of the main window in the
graphical user interface.
i
Provide this preference in the command line arguments to enable
interactive profile manager in the text user interface.
Currently only profile listing and interactive selection are
available. Preferences like batch and silent remain applicable
to synchronization functionality.
ignore xxx
Including the preference -ignore pathspec causes Unison to
completely ignore paths that match pathspec (as well as their
children). This is useful for avoiding synchronizing temporary
files, object files, etc. The syntax of pathspec is described in
the section “Path Specification” , and further details on
ignoring paths is found in the section “Ignoring Paths” .
ignorearchives
When this preference is set, Unison will ignore any existing
archive files and behave as though it were being run for the
first time on these replicas. It is not a good idea to set this
option in a profile: it is intended for command-line use.
ignorecase xxx
When set to true, this flag causes Unison to treat filenames as
case insensitive—i.e., files in the two replicas whose names
differ in (upper- and lower-case) ‘spelling’ are treated as the
same file. When the flag is set to false, Unison will treat all
filenames as case sensitive. Ordinarily, when the flag is set to
default, filenames are automatically taken to be
case-insensitive if either host is running Windows or OSX. In
rare circumstances it may be useful to set the flag manually.
ignoreinodenumbers
When set to true, this preference makes Unison not take
advantage of inode numbers during fast update detection. This
switch should be used with care, as it is less safe than the
standard update detection method, but it can be useful with
filesystems which do not support inode numbers.
ignorelocks
When this preference is set, Unison will ignore any lock files
that may have been left over from a previous run of Unison that
was interrupted while reading or writing archive files; by
default, when Unison sees these lock files it will stop and
request manual intervention. This option should be set only if
you are positive that no other instance of Unison might be
concurrently accessing the same archive files (e.g., because
there was only one instance of unison running and it has just
crashed or you have just killed it). It is probably not a good
idea to set this option in a profile: it is intended for
command-line use.
ignorenot xxx
This preference overrides the preference ignore. It gives a list
of patterns (in the same format as ignore) for paths that should
definitely not be ignored, whether or not they happen to match
one of the ignore patterns.
immutablenot xxx
This preference overrides immutable.
include xxx
Include preferences from a profile. include name reads the
profile "name" (or file "name" in the .unison directory if
profile "name" does not exist) and includes its contents as if
it was part of a profile or given directly on command line.
key xxx
Used in a profile to define a numeric key (0-9) that can be used
in the user interface to switch immediately to this profile.
killserver
When set to true, this flag causes Unison to kill the remote
server process when the synchronization is finished. This
behavior is the default for ssh connections, so this preference
is not normally needed when running over ssh; it is provided so
that socket-mode servers can be killed off after a single run of
Unison, rather than waiting to accept future connections. (Some
users prefer to start a remote socket server for each run of
Unison, rather than leaving one running all the time.)
label xxx
Used in a profile to provide a descriptive string documenting
its settings. (This is useful for users that switch between
several profiles, especially using the ‘fast switch’ feature of
the graphical user interface.)
links xxx
When set to true, this flag causes Unison to synchronize
symbolic links. When the flag is set to false, symbolic links
will be ignored during update detection. Ordinarily, when the
flag is set to default, symbolic links are synchronized except
when one of the hosts is running Windows. On a Windows client,
Unison makes an attempt to detect if symbolic links are
supported and allowed by user privileges. You may have to get
elevated privileges to create symbolic links. When the flag is
set to default and symbolic links can’t be synchronized then an
error is produced during update detection.
listen xxx
When acting as a server on a TCP socket, Unison will by default
listen on "any" address (0.0.0.0 and [::]). This command-line
argument allows to specify a different listening address and can
be repeated to listen on multiple addresses. Listening address
can be specified as a host name or an IP address.
log
When this flag is set, Unison will log all changes to the
filesystems on a file.
logfile xxx
By default, logging messages will be appended to the file
unison.log in your .unison directory. Set this preference if you
prefer another file. It can be a path relative to your .unison
directory. Sending SIGUSR1 will close the logfile; the logfile
will be re-opened (and created, if needed) automatically, to
allow for log rotation.
maxbackups n
This preference specifies the number of backup versions that
will be kept by unison, for each path that matches the predicate
backup. The default is 2.
maxerrors n
This preference controls after how many errors Unison aborts a
directory transfer. Setting it to a large number allows Unison
to transfer most of a directory even when some files fail to be
copied. The default is 1. If the preference is set too high,
Unison may take a long time to abort in case of repeated
failures (for instance, when the disk is full).
maxsizethreshold n
A number indicating above what filesize (in kilobytes) Unison
should flag a conflict instead of transferring the file. This
conflict remains even in the presence of force or prefer
options. A negative number will allow every transfer
independently of the size. The default is -1.
maxthreads n
This preference controls how much concurrency is allowed during
the transport phase. Normally, it should be set reasonably high
to maximize performance, but when Unison is used over a
low-bandwidth link it may be helpful to set it lower (e.g. to 1)
so that Unison doesn’t soak up all the available bandwidth. The
default is the special value 0, which mean 20 threads when file
content streaming is deactivated and 1000 threads when it is
activated.
merge xxx
This preference can be used to run a merge program which will
create a new version for each of the files and the backup, with
the last backup and both replicas. The syntax of pathspec -> cmd
is described in the section “Path Specification” , and further
details on Merging functions are present in the section “Merging
Conflicting Versions” .
mountpoint xxx
Including the preference -mountpoint PATH causes Unison to
double-check, at the end of update detection, that PATH exists
and abort if it does not. This is useful when Unison is used to
synchronize removable media. This preference can be given more
than once. See the section “Mount Points and Removable Media” .
nocreation xxx
Including the preference -nocreation root prevents Unison from
performing any file creation on root root.
You can also specify a unique prefix or suffix of the path of
one of the roots or a unique prefix of the hostname of a remote
root.
nocreationpartial xxx
Including the preference nocreationpartial = PATHSPEC -> root
prevents Unison from performing any file creation in PATHSPEC on
root root (see the section “Path Specification” for more
information). It is recommended to use BelowPath patterns when
selecting a directory and all its contents.
nodeletion xxx
Including the preference -nodeletion root prevents Unison from
performing any file deletion on root root.
nodeletionpartial xxx
Including the preference nodeletionpartial = PATHSPEC -> root
prevents Unison from performing any file deletion in PATHSPEC on
root root (see the section “Path Specification” for more
information). It is recommended to use BelowPath patterns when
selecting a directory and all its contents.
noupdate xxx
Including the preference -noupdate root prevents Unison from
performing any file update or deletion on root root.
noupdatepartial xxx
Including the preference noupdatepartial = PATHSPEC -> root
prevents Unison from performing any file update or deletion in
PATHSPEC on root root (see the section “Path Specification” for
more information). It is recommended to use BelowPath patterns
when selecting a directory and all its contents.
numericids
When this flag is set to true, groups and users are synchronized
numerically, rather than by name.
The special uid 0 and the special group 0 are never mapped via
user/group names even if this preference is not set.
owner
When this flag is set to true, the owner attributes of the files
are synchronized. Whether the owner names or the owner
identifiers are synchronizeddepends on the preference numerids.
path xxx
When no path preference is given, Unison will simply synchronize
the two entire replicas, beginning from the given pair of roots.
If one or more path preferences are given, then Unison will
synchronize only these paths and their children. (This is useful
for doing a fast sync of just one directory, for example.) Note
that path preferences are interpreted literally—they are not
regular expressions.
perms n
The integer value of this preference is a mask indicating which
permission bits should be synchronized. It is set by default to
0o1777: all bits but the set-uid and set-gid bits are
synchronised (synchronizing these latter bits can be a security
hazard). If you want to synchronize all bits, you can set the
value of this preference to −1. If one of the replica is on a
FAT [Windows] filesystem, you should consider using the fat
preference instead of this preference. If you need Unison not to
set permissions at all, set the value of this preference to 0
and set the preference dontchmod to true.
prefer xxx
Including the preference -prefer root causes Unison always to
resolve conflicts in favor of root, rather than asking for
guidance from the user, except for paths marked by the
preference merge. (The syntax of root is the same as for the
root preference, plus the special values newer and older.)
This preference should be used only if you are sure you know
what you are doing!
preferpartial xxx
Including the preference preferpartial = PATHSPEC -> root causes
Unison always to resolve conflicts in favor of root, rather than
asking for guidance from the user, for the files in PATHSPEC
(see the section “Path Specification” for more information).
(The syntax of root is the same as for the root preference, plus
the special values newer and older.)
This preference should be used only if you are sure you know
what you are doing!
repeat xxx
Setting this preference causes the text-mode interface to
synchronize repeatedly, rather than doing it just once and
stopping. If the argument is a number, Unison will pause for
that many seconds before beginning again. When the argument is
watch, Unison relies on an external file monitoring process to
synchronize whenever a change happens. You can combine the two
with a + character to use file monitoring and also do a full
scan every specified number of seconds. For example, watch+3600
will react to changes immediately and additionally do a full
scan every hour.
retry n
Setting this preference causes the text-mode interface to try
again to synchronize updated paths where synchronization fails.
Each such path will be tried N times.
root xxx
Each use of this preference names the root of one of the
replicas for Unison to synchronize. Exactly two roots are
needed, so normal modes of usage are either to give two values
for root in the profile, or to give no values in the profile and
provide two on the command line. Details of the syntax of roots
can be found in the section “Roots” .
The two roots can be given in either order; Unison will sort
them into a canonical order before doing anything else. It also
tries to ‘canonize’ the machine names and paths that appear in
the roots, so that, if Unison is invoked later with a slightly
different name for the same root, it will be able to locate the
correct archives.
rootalias xxx
When calculating the name of the archive files for a given pair
of roots, Unison replaces any roots matching the left-hand side
of any rootalias rule by the corresponding right-hand side.
rsrc xxx
When set to true, this flag causes Unison to synchronize
resource forks and HFS meta-data. On filesystems that do not
natively support resource forks, this data is stored in
Carbon-compatible ._ AppleDouble files. When the flag is set to
false, Unison will not synchronize these data. Ordinarily, the
flag is set to default, and these data are automatically
synchronized if either host is running OSX. In rare
circumstances it is useful to set the flag manually.
rsync
Unison uses the ’rsync algorithm’ for ’diffs-only’ transfer of
updates to large files. Setting this flag to false makes Unison
use whole-file transfers instead. Under normal circumstances,
there is no reason to do this, but if you are having trouble
with repeated ’rsync failure’ errors, setting it to false should
permit you to synchronize the offending files.
selftest
Run internal tests and exit. This option is mostly for
developers and must be used carefully: in particular, it will
delete the contents of both roots, so that it can install its
own files for testing. This flag only makes sense on the command
line. When it is provided, no preference file is read: all
preferences must be specified on thecommand line. Also, since
the self-test procedure involves overwriting the roots and
backup directory, the names of the roots and of the backupdir
preference must include the string "test" or else the tests will
be aborted. (If these are not given on the command line, dummy
subdirectories in the current directory will be created
automatically.)
servercmd xxx
This preference can be used to explicitly set the name of the
Unison executable on the remote server (e.g., giving a full path
name), if necessary.
showarchive
When this preference is set, Unison will print out the ’true
names’of the roots, in the same form as is expected by the
rootalias preference.
silent
When this preference is set to true, the textual user interface
will print nothing at all, except in the case of errors. Setting
silent to true automatically sets the batch preference to true.
socket xxx
Start unison as a server listening on a TCP socket (with TCP
port number as argument) or a local socket (aka Unix domain
socket) (with socket path as argument).
sortbysize
When this flag is set, the user interface will list changed
files by size (smallest first) rather than by name. This is
useful, for example, for synchronizing over slow links, since it
puts very large files at the end of the list where they will not
prevent smaller files from being transferred quickly.
This preference (as well as the other sorting flags, but not the
sorting preferences that require patterns as arguments) can be
set interactively and temporarily using the ’Sort’ menu in the
graphical and text user interfaces.
sortfirst xxx
Each argument to sortfirst is a pattern pathspec, which
describes a set of paths. Files matching any of these patterns
will be listed first in the user interface. The syntax of
pathspec is described in the section “Path Specification” .
sortlast xxx
Similar to sortfirst, except that files matching one of these
patterns will be listed at the very end.
sortnewfirst
When this flag is set, the user interface will list newly
created files before all others. This is useful, for example,
for checking that newly created files are not ‘junk’, i.e., ones
that should be ignored or deleted rather than synchronized.
source xxx
Include preferences from a file. source name reads the file
"name" in the .unison directory and includes its contents as if
it was part of a profile or given directly on command line.
sshargs xxx
The string value of this preference will be passed as additional
arguments (besides the host name and the name of the Unison
executable on the remote system) to the ssh command used to
invoke the remote server. The backslash is an escape character.
sshcmd xxx
This preference can be used to explicitly set the name of the
ssh executable (e.g., giving a full path name), if necessary.
stream
(Deprecated) When this preference is set, Unison will use an
experimental streaming protocol for transferring file contents
more efficiently. The default value is true.
terse
When this preference is set to true, the user interface will not
print status messages.
testserver
Setting this flag on the command line causes Unison to attempt
to connect to the remote server and, if successful, print a
message and immediately exit. Useful for debugging installation
problems. Should not be set in preference files.
times
When this flag is set to true, file modification times (but not
directory modtimes) are propagated.
ui xxx
This preference selects either the graphical or the textual user
interface. Legal values are graphic or text.
unicode xxx
When set to true, this flag causes Unison to perform case
insensitive file comparisons assuming Unicode encoding. This is
the default. When the flag is set to false, Latin 1 encoding is
assumed (this means that all bytes that are not letters in Latin
1 encoding will be compared byte-for-byte, even if they may be
valid characters in some other encoding). When Unison runs in
case sensitive mode, this flag only makes a difference if one
host is running Mac OS X. Under Mac OS X, it selects whether
comparing the filenames up to decomposition, or byte-for-byte.
version
Print the current version number and exit. (This option only
makes sense on the command line.)
watch
Unison uses a file watcher process, when available, to detect
filesystem changes; this is used to speed up update detection.
Setting this flag to false disables the use of this process.
xattrignore xxx
Preference -xattrignore namespec causes Unison to ignore
extended attributes with names that match namespec. This can be
used to exclude extended attributes that would fail
synchronization due to lack of permissions or technical
differences at replicas. The syntax of namespec is the same as
used for path specification (described in the section “Path
Specification” ); prefer the Path and Regex forms over the Name
form. The pattern is applied to the name of extended attribute,
not to path. On Linux, attributes in the security and trusted
namespaces are ignored by default (this is achieved by pattern
Regex !(security|trusted)[.].*); also attributes used to store
POSIX ACL are ignored by default (this is achieved by pattern
Path !system.posix_acl_*). To sync attributes in one or both of
these namespaces, see the xattrignorenot preference. Note that
the namespace name must be prefixed with a "!" (applies on Linux
only). All names not prefixed with a "!" are taken as strictly
belonging to the user namespace and therefore the "!user."
prefix is never used.
xattrignorenot xxx
This preference overrides the preference xattrignore. It gives a
list of patterns (in the same format as xattrignore) for
extended attributes that should not be ignored, whether or not
they happen to match one of the xattrignore patterns. It is
possible to synchronize only desired attributes by ignoring all
attributes (for example, by setting xattrignore to Path * and
then adding xattrignorenot for extended attributes that should
be synchronized. On Linux, attributes in the security and
trusted namespaces are ignored by default. To sync attributes in
one or both of these namespaces, you may add an xattrignorenot
pattern like Path !security.* to sync all attributes in the
security namespace, or Path !security.selinux to sync a specific
attribute in an otherwise ignored namespace. A pattern like Path
!system.posix_acl_* can be used to sync POSIX ACLs on Linux.
Note that the namespace name must be prefixed with a "!"
(applies on Linux only). All names not prefixed with a "!" are
taken as strictly belonging to the user namespace and therefore
the "!user." prefix is never used.
xattrs
When this flag is set to true, the extended attributes of files
and directories are synchronized. System extended attributes are
not synchronized.
xferbycopying
When this preference is set, Unison will try to avoid
transferring file contents across the network by recognizing
when a file with the required contents already exists in the
target replica. This usually allows file moves to be propagated
very quickly. The default value is true.
Profiles
A profile may include blank lines and lines beginning with #; both are
ignored.
Spaces and tabs before and after p and xxx are ignored. Spaces, tabs,
and non-printable characters within values are not treated specially,
so that e.g. root = /foo bar refers to a directory containing a space.
(On systems using newline for line ending, carriage returns are
currently ignored, but this is not part of the specification.)
When Unison starts, it first reads the profile and then the command
line, so command-line options will override settings from the profile.
Profiles may also include lines of the form include name, which will
cause the file name (or name.prf, if name does not exist in the .unison
directory) to be read at the point, and included as if its contents,
instead of the include line, was part of the profile. Include lines
allows settings common to several profiles to be stored in one place. A
similar line of the form source name does the same except that it does
not attempt to add a suffix to name. Similar lines of the form include?
name or source? name do the same as their respective lines without the
question mark except that it does not constitute an error to specify a
non-existing file name. In name the backslash is an escape character.
Sample Profiles
A Minimal Profile
Here is a very minimal profile file, such as might be found in
.unison/default.prf:
# Roots of the synchronization
root = /home/bcpierce
root = ssh://saul//home/bcpierce
# Paths to synchronize
path = current
path = common
path = .netscape/bookmarks.html
A Basic Profile
# Paths to synchronize
path = current
path = common
path = .netscape/bookmarks.html
# Window height
height = 37
A Power-User Profile
Note that the name of the common file is common, not common.prf; this
prevents Unison from offering common as one of the list of profiles in
the opening dialog (in the graphical UI).
Note that there are no path preferences in common. This means that,
when we invoke Unison with the default profile (e.g., by typing ’unison
default’ or just ’unison’ on the command line), the whole replicas will
be synchronized. (If we never want to synchronize the whole replicas,
then default.prf would instead include settings for all the paths that
are usually synchronized.)
then pressing 2 will cause Unison to look for updates in the Mail
subdirectory and (because the batch flag is set) immediately propagate
any that it finds.
Keeping Backups
When Unison overwrites (or deletes) a file or directory while
propagating changes from the other replica, it can keep the old version
around as a backup. There are several preferences that control
precisely where these backups are stored and how they are named.
To enable backups, you must give one or more backup preferences. Each
of these has the form
backup = <pathspec>
where <pathspec> has the same form as for the ignore preference. For
example,
backup = Name *
When backups are stored locally, they are kept in the same directory as
the original.
When backups are stored centrally, the directory used to hold them is
controlled by the preference backupdir and the environment variable
UNISONBACKUPDIR. (The environment variable is checked first.) If
neither of these are set, then the directory .unison/backup in the
user’s home directory is used.
Other than maxbackups (which will never delete the last backup), there
are no other mechanisms for deleting backups.
The <PATHSPEC> here has exactly the same format as for the ignore
preference (see the section “Path Specification” ). For example, using
“Name *.txt” as the <PATHSPEC> tells Unison that this command should be
used whenever a file with extension .txt needs to be merged.
Many external merging programs require as inputs not just the two files
that need to be merged, but also a file containing the last
synchronized version. You can ask Unison to keep a copy of the last
synchronized version for some files using the backupcurrent preference.
This preference is used in exactly the same way as backup and its
meaning is similar, except that it causes backups to be created of the
current contents of each file after it has been synchronized by Unison,
rather than the previous contents that Unison overwrote. These backups
are stored in both replicas in the same place as ordinary backup
files—i.e. according to the backuplocation and backupdir preferences.
They are named like the original files if backupslocation is set to
’central’ and otherwise, Unison uses the backupprefix and backupsuffix
preferences and assumes a version number 000 for these backups. Note
that there are no mechanisms (beyond the limit on the number of backups
for each file) to remove backup files.
You can detect batch mode by testing BATCHMODE; for example to avoid a
merge completely do nothing:
merge = Name *.txt -> [ -z "BATCHMODE" ] && mergecmd CURRENT1 CURRENT2
will tell Unison to use the external diff3 program for merging.
Alternatively, users of emacs may find the following settings
convenient:
merge = Name *.txt -> emacs -q --eval '(ediff-merge-files-with-ancestor
"CURRENT1" "CURRENT2" "CURRENTARCH" nil "NEW")'
(These commands are displayed here on two lines to avoid running off
the edge of the page. In your preference file, each command should be
written on a single line.)
Users running emacs under windows may find something like this useful:
merge = Name * -> C:\Progra~1\Emacs\emacs\bin\emacs.exe -q --eval
"(ediff-files """CURRENT1""" """CURRENT2""")"
Users running Mac OS X (you may need the Developer Tools installed to
get the opendiff utility) may prefer
merge = Name *.txt -> opendiff CURRENT1 CURRENT2 -ancestor CURRENTARCH -merg
e NEW
Here is a slightly more involved hack. The opendiff program can operate
either with or without an archive file. A merge command of this form
merge = Name *.txt ->
if [ CURRENTARCHOPTx = x ];
then opendiff CURRENT1 CURRENT2 -merge NEW;
else opendiff CURRENT1 CURRENT2 -ancestor CURRENTARCHOPT -merge NE
W;
fi
(still all on one line in the preference file!) will test whether an
archive file exists and use the appropriate variant of the arguments to
opendiff.
Ordinarily, external merge programs are only invoked when Unison is not
running in batch mode. To specify an external merge program that should
be used no matter the setting of the batch flag, use the mergebatch
preference instead of merge.
Both the textual and the graphical user interfaces are intended to be
mostly self-explanatory. Here are just a few tricks:
* By default, when running on Unix the textual user interface will
try to put the terminal into the “raw mode” so that it reads the
input a character at a time rather than a line at a time. (This
means you can type just the single keystroke “>” to tell Unison to
propagate a file from left to right, rather than “> Enter.”)
There are some situations, though, where this will not work — for
example, when Unison is running in a shell window inside Emacs.
Setting the dumbtty preference will force Unison to leave the
terminal alone and process input a line at a time.
Interrupting a Synchronization
Graphical Interface:
* In the graphical user interface the synchronization process can be
interrupted before it is finished by pressing the “Stop” button or
by closing the window. The “Stop” button causes the onging
propagation to be stopped as quickly as possible while still doing
proper cleanup. The application keeps running and a rescan can be
performed or a different profile selected. Closing the window in
the middle of update propagation process will exit the application
immediately without doing proper cleanup; it is therefore not
recommended unless the “Stop” button does not react quickly enough.
Textual Interface:
* When not synchronizing continuously, the text interface terminates
when synchronization is finished normally or due to a fatal error
occurring.
In the text interface, to interrupt synchronization before it is
finished, press “Ctrl-C” (or send signal SIGINT or SIGTERM). This
will interrupt update propagation as quickly as possible but still
complete proper cleanup. If the process does not stop even after
pressing “Ctrl-C” then keep doing it repeatedly. This will bypass
cleanup procedures and terminates the process forcibly (similar to
SIGKILL). Doing so may leave the archives or replicas in an
inconsistent state or locked.
When synchronizing continuously (time interval repeat or with
filesystem monitoring), interrupting with “Ctrl-C” or with signal
SIGINT or SIGTERM works the same way as described above and will
additionally stop the continuous process. To stop only the
continuous process and let the last synchronization complete
normally, send signal SIGUSR2 instead.
Exit Code
When running in the textual mode, Unison returns an exit status, which
describes whether, and at which level, the synchronization was
successful. The exit status could be useful when Unison is invoked from
a script. Currently, there are four possible values for the exit
status:
* 0: successful synchronization; everything is up-to-date now.
* 1: some files were skipped, but all file transfers were successful.
* 2: non-fatal failures occurred during file transfer.
* 3: a fatal error occurred, or the execution was interrupted.
The graphical interface does not return any useful information through
the exit status.
Path Specification
matches the path path and any path below. The name and path
arguments of the latter forms of patterns are not regular
expressions. Instead, standard “globbing” conventions can be used
in name and path:
+ a * matches any sequence of characters not including / (and
not beginning with ., when used at the beginning of a name)
+ a ? matches any single character except / (and leading .)
+ [xyz] matches any character from the set {x, y, z }
+ {a,bb,ccc} matches any one of a, bb, or ccc. (Be careful not
to put extra spaces after the commas: these will be
interpreted literally as part of the strings to be matched!)
* The path separator in path patterns is always the forward-slash
character “/” — even when the client or server is running under
Windows, where the normal separator character is a backslash. This
makes it possible to use the same set of path patterns for both
Unix and Windows file systems.
* A path specification may be followed by the separator “ -> ” itself
followed by a string which will be associated to the matching
paths:
Path path -> associated string
Not all pathspec preferences use these associated strings but all
pathspec preferences are parsed identically and the strings may be
ignored. Only the last match of the separator string on the line is
used as a delimiter. Thus to allow a path specification to contain
the separator string, append an associated string to it, even if it
is not used. The associated string cannot contain the separator
string.
Ignoring Paths
Most users of Unison will find that their replicas contain lots of
files that they don’t ever want to synchronize — temporary files, very
large files, old stuff, architecture-specific binaries, etc. They can
instruct Unison to ignore these paths using patterns introduced in the
section “Path Specification” .
For example, the following pattern will make Unison ignore any path
containing the name CVS or a name ending in .cmo:
ignore = Name {CVS,*.cmo}
Path patterns do not skip filenames beginning with . (as Name patterns
do). For example,
ignore = Path */tmp
The following pattern makes Unison ignore any path beginning with a/b
and ending with a name ending by .ml.
ignore = Regex a/b/.*\.ml
Note that regular expression patterns are “anchored”: they must match
the whole path, not just a substring of the path.
Symbolic Links
Not all Windows versions and file systems support symbolic links;
Unison will refuse to propagate an opaque symbolic link from Unix to
Windows and flag the path as erroneous if the support or privileges are
lacking on the Windows side. When a Unix replica is to be synchronized
with such Windows system, all symbolic links should match either an
ignore pattern or a follow pattern.
You may need to acquire extra privileges to create symbolic links under
Windows. By default, this is only allowed for administrators. Unison
may not be able to automatically detect support for symbolic links
under Windows. In that case, set the preference links to true
explicitly.
Permissions
If one of the replicas does not support any type of ACLs then Unison
will not attempt ACL synchronization. If the other replica does support
ACLs then those will remain intact.
If both replicas support ACLs of any supported type then you can
request Unison to try ACL synchronization (acl preference). Success of
synchronization depends on permissions of the owner and group of Unison
process (Unison must have permissions to set ACL) and the compatibility
of ACL types on both replicas.
Not all filesystems on the listed platforms support all ACL types (or
any ACLs at all).
If one of the replicas does not support extended attributes then Unison
will not attempt attribute synchronization. If the other replica does
support extended attributes then those will remain intact.
Caveats:
* Some platforms and file systems support very large extended
attribute values. Unison synchronizes only up to 16 MB of each
attribute value.
* Attributes are synchronized as simple name-value pairs. More
complex extended attribute concepts supported by some platforms are
not synchronized.
* On Linux, attribute names always have a fully qualified form
(namespace.attribute). Other platforms do not have the same
constraint. The consequence of this is that Unison will sync the
attribute names on Linux as follows: an ! is prepended to the
namespace name, except for the user namespace; the user. prefix is
stripped from attribute names instead. This allows syncing extended
attributes from Linux to other platforms. These transformations are
reversed when syncing to Linux, resulting in correct fully
qualified attribute names. The xattrignore and xattrignorenot
preferences work on the transformed attribute names. This means
that any patterns for the user namespace must be specified without
the user. prefix and any patterns intended for other namespaces
must begin with an !.
Cross-Platform Synchronization
Case conflicts. In Unix, filenames are case sensitive: foo and FOO can
refer to different files. In Windows, on the other hand, filenames are
not case sensitive: foo and FOO can only refer to the same file. This
means that a Unix foo and FOO cannot be synchronized onto a Windows
system — Windows won’t allow two different files to have the “same”
name. Unison detects this situation for you, and reports that it cannot
synchronize the files.
You can deal with a case conflict in a couple of ways. If you need to
have both files on the Windows system, your only choice is to rename
one of the Unix files to avoid the case conflict, and re-synchronize.
If you don’t need the files on the Windows system, you can simply
disregard Unison’s warning message, and go ahead with the
synchronization; Unison won’t touch those files. If you don’t want to
see the warning on each synchronization, you can tell Unison to ignore
the files (see the section “Ignoring Paths” ).
Slow Links
Unison is built to run well even over relatively slow links such as
modems and DSL connections.
Unison uses the “rsync protocol” designed by Andrew Tridgell and Paul
Mackerras to greatly speed up transfers of large files in which only
small changes have been made. More information about the rsync protocol
can be found at the rsync web site (http://samba.anu.edu.au/rsync/).
If you are using Unison with ssh, you may get some speed improvement by
enabling ssh’s compression feature. Do this by adding the option
“-sshargs -C” to the command line or “sshargs = -C” to your profile.
If you have rsync installed on both hosts, you can make Unison use it
simply by setting the copythreshold flag to something non-negative. If
you set it to 0, Unison will use the external copy utility for all
whole-file transfers. (This is probably slower than letting Unison copy
small files by itself, but can be useful for testing.) If you set it to
a larger value, Unison will use the external utility for all files
larger than this size (which is given in kilobytes, so setting it to
1000 will cause the external tool to be used for all transfers larger
than a megabyte).
If you want to use a different external copy utility, set both the
copyprog and copyprogrest preferences—the former is used for the first
transfer of a file, while the latter is used when Unison sees a
partially transferred temp file on the receiving host. Be careful here:
Your external tool needs to be instructed to copy files in place
(otherwise if the transfer is interrupted Unison will not notice that
some of the data has already been transferred, the next time it tries).
The default values are:
copyprog = rsync --inplace --compress
copyprogrest = rsync --partial --inplace --compress
Using Unison removable media such as USB drives can be dangerous unless
you are careful. If you synchronize a directory that is stored on
removable media when the media is not present, it will look to Unison
as though the whole directory has been deleted, and it will proceed to
delete the directory from the other replica—probably not what you want!