logo

dmpop

Aircraft photography, spaghetti code, half-baked thoughts

Guestbook Reads
Currently reading: Gli occhi di Venezia, Alessandro Barbero


Unison: Syncing up with an old friend

When I need to update content of this very Tinble-based blog, I usually do that via SSH. It's a simple solution that works, but it does have drawbacks. Firstly, there is no backup: I edit original files, so if something goes wrong, my work might be gone for good. Secondly, working via an SSH connection can be very slow when I'm on the move. Not to mention that SSH is all but useless without an internet connection.

An ideal solution would be to have local replicas of the content directory on every machine that I use, and let a synchronization tool to keep the source directory and all the replicas in sync. Of course, I could use rsync, but it's a pain to have to remember which way I have to push changes. Something like Git or Syncthing could be an option too, but I didn't feel like over-engineering.

And then I remembered — Unison! It served me well ages ago, and I'm actually not quite sure why I stopped using it. Anyway, I was surprised to discover that Unison is still actively maintained, and the project is now hosted on GitHub. Better still, both Linux Mint and Debian have newer versions of the Unison command-line tool and its GTK-based GUI sibling in their official software repositories, so installing the packages on my local machines and servers was a matter of running the following command:

sudo apt install unison unison-gtk
For Unison to do it syncing magic, it must be installed on all machines you want to use for syncing

Unison's most appealing trait is its supreme simplicity, especially if you choose to use the GUI utility. On the first run, it walks you through a short and simple process of setting up a synchronization profile. Once you're done, it's a matter of triggering synchronization by pressing Go (or the G keyboard key). You can create as many synchronization profiles as needed, and the all saved as plain-text .prf files in the ~/.unison directory. This means that you can easily back up profiles and move them across multiple machines.

Unison graphical user interface screenshot

Unison can sync data between local and remove directories either via SSH of a TCP socket. The latter is not secure by default, and it requires running the Unison server on the remote machine using the unison -server 1111 command (where 1111 is the desired port). In other words, it's not as good as SSH, but it can come in useful when using SSH is not an option.

It goes without saying that Unison provides a flexible conflict resolution mechanism for dealing with synchronization conflicts, should they occur.

Having a weak spot for simple yet reliable tools, I was pleased to re-discover Unison. It was like seeing an old and trusty friend after a long time, and it has been a joyful reunion indeed.


Published: 2024-10-04Reads: 441
Comment by emailBack
dmpop

dmpop

Linux user, amateur photographer, aviation enthusiast, clueless developer of ADS-B station, Pellicola and Tinble, author of a bunch of books. I can mix a decent Negroni, too. You can reach me at me@dmpop.xyz