Data synchronization over the Internet with Unison
First Sync
For an initial sync, I will be assuming the following initial scenario. The file tree to be synchronized is completely filled on the server; on the client, it is completely empty, except for the Unison profiles in ~/.unison/
and the SSH certificate in ~/.ssh/
. In this ideal state, the server thus exclusively acts as the source, and the client exclusively acts as the sync target.
If another state exists, you need to prepare for a longer session, because then many conflicts can occur on the first attempt. All of them need to be handled with the greatest care – otherwise you could easily shoot yourself in the foot. Under no circumstances must the client contain the remains of any Unison sync archives in the directory ~/.unison/
.
You trigger this initial sync in the same way as for mobile devices in the following section. You will then see the warning shown in Figure 2 in response. In it, Unison announces that this is obviously an initial sync, which could take a little longer.
Mobile Operation
The mode for mobile operation is mainly – but, as explained later, not exclusively – intended for devices like the mobile.myprovider.tld
laptop in Figure 1. For this simple operating mode, a quite straightforward profile (Listing 4) is all you need; you can save this as mobile.prf
. It ensures that the unison-fsmonitor
filesystem monitor does not launch under any circumstances (line 7) and that only the basic sync takes place in line with the specifications from Listing 3 (line 11 in Listing 4).
Listing 4
mobile.prf
To start the synchronization, it makes sense to launch the graphical application. At the command line, type unison-gtk mobile
. Since running the program from the prompt is not entirely intuitive, you will want to create an appropriate shortcut on the desktop, in the taskbar, or in the application menu.
After starting Unison, wait until the application shows you the differences between the two replicas (Figure 3). In the simplest case, if the sync suggested by the green arrows is what you expected, then press Go and wait for the end of the synchronization run. Even in the case of conflicts marked with red question marks, you can start the sync with a clear conscience: Unison then only processes the updates with the green arrows and leaves the conflicts untouched.
Authentication
Whenever it is called, Unison prompts you for the passphrase of the certificate for the SSH connection (Figure 4). As long as you do not close the unison-gtk
user interface after you have entered your data, you can perform as many syncs as you like without having to re-enter it. This is a pretty ugly hack, though.
It makes far more sense to integrate the unison-mobile.sh
shell script in Listing 5 into the desktop environment so that it is called automatically at login time. Then the passphrase request is only made once in order to release the SSH certificate for the server for the duration of the session. It is then available for any number of syncs – and for regular SSH sessions.
Listing 5
unison-mobile.sh
If you not only enter the passphrase, but also check the Save Password box as shown in Figure 5, the desktop stores the passphrase in its wallet, and you will not need to query it again for future logins.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs