Unison is an excellent solution for synchronizing and
transferring entire directory trees. The synchronization is performed
in both directions and can be controlled by means of an intuitive
graphical front-end. A console version can also be used. The
synchronization can be automated so interaction with the user is not
required, but experience is necessary.
37.3.1 Requirements
Unison must be installed on the client as well as on the
server. In this context, the term server refers
to a second, remote host (unlike CVS, explained in Section 37.1.2,
CVS).
In the following section, Unison is used together with ssh. In
this case, an SSH client must be installed on the client and an SSH
server must be installed on the server.
37.3.2 Using Unison
The approach used by Unison is the association of two
directories (roots) with each other. This
association is symbolic—it is not an online connection. In
this example, the directory layout is as follows:
You want to synchronize these two directories. The user is
known as tux on the client and as geeko on the server. The first thing
to do is to test if the client-server communication works:
unison -testserver /home/tux/dir1 ssh://geeko@server//homes/geeko/dir2
The most frequently encountered problems are:
-
The Unison versions used on the client and server are not
compatible.
-
The server does not allow SSH connections.
-
Neither of the two specified paths exists.
If everything works, omit the option
-testserver. During the first synchronization,
Unison does not yet know the relationship between the two
directories and submits suggestions for the transfer direction of
the individual files and directories. The arrows in the
column indicate the transfer direction. A
question mark means that Unison is not able to make a suggestion
regarding the transfer direction because both versions were changed
or are new.
The arrow keys can be used to set the transfer direction for
the individual entries. If the transfer directions are correct for
all displayed entries, simply click .
The characteristics of Unison (for example, whether to perform
the synchronization automatically in clear cases) can be controlled
by means of command-line parameters specified when the program is
started. View the complete list of all parameters with
unison --help.
Example 37-1
The file ~/.unison/example.prefs
root=/home/tux/dir1
root=ssh://wilber@server//homes/wilber/dir2
batch=true
For each pair, a synchronization log is maintained in the user
directory ~/.unison. Configuration sets, such
as ~/.unison/example.prefs, can also be stored
in this directory. To start the synchronization, specify this file
as the command-line parameter as in
unison example.prefs.