Data synchronization over the Internet with Unison
Handling Conflicts
After synchronization, the Unison user interface displays the results in a clear-cut overview (Figure 6). Successfully synchronized files are marked with a green check mark; a summary lists the remaining conflicts. If you now press Rescan and compare the replicas again, all the successfully matched files will disappear and only the conflicts will remain.
Select the conflicts one by one and prepare them for a new sync by selecting Skip, Left to Right, or Right to Left. Unison shows the approach chosen for conflict resolution with blue arrows (Figure 7). Another click on Go then triggers the sync.
Stationary Operation
The stationary.prf
profile (Listing 6) is intended for computers with a permanent network connection, such as the workstations private.myhome.tld
and work.myoffice.tld
(see Figure 1).
Listing 6
stationary.prf
Activating batch mode and other modes in lines 9 to 11 means that Unison runs completely in the background, no longer asks you any questions, and synchronizes everything that it can without a conflict occurring. Line 12 additionally switches on the unison-fsmonitor
automatic filesystem monitor in the background, which ensures a quick comparison as soon as something changes in one of the two replicas.
Due to the fact that the connection is established during login and is only closed again at logout time, there is permanent communication between client and server. This is handled by the unison-stationary.sh
shell script (Listing 7), which you need to add to the list of autostart scripts. On KDE Plasma, for example, put it in the ~/.config/autostart-scripts/
directory.
Listing 7
unison-stationary.sh
Line 6 in Listing 7 activates the SSH certificate – as above for mobile operation – and loads it for the session. Line 7 starts Unison in text mode and as a background process with the profile from Listing 6. From now on and until you log out, every change in the filesystem on one of the two sides triggers a real-time comparison in the background and is logged in the logfile. Conflicts seemingly disappear, but can be detected at any time by calling unison-gtk mobile
in the GUI and handled accordingly.
Conclusions
Unison v2.48.4 is a very reliable, powerful, and efficient tool for bidirectional synchronization of filesystems between computers. In combination with SSH, this comparison can also be carried out securely over the Internet with regard to authentication and data transport. Smaller synchronization runs optimize the solution for mobile or stationary operation.
Unison's GUI clearly shows the differences between the two replicas and supports the user in resolving conflicts. With the configuration shown here, databases can be kept up to date across several computers, which allows the user to freely and quickly switch between workstations.
Infos
- Unison: https://www.cis.upenn.edu/~bcpierce/unison/
- OpenSSH: https://www.openssh.com
- Unison 2.48.4 (source code): https://github.com/bcpierce00/unison/archive/2.48.4.tar.gz
- Profiles: https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#profile
- Path specification: https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#pathspec
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)