Unison – How to Run Unison Between Ubuntu and CentOS 7

unison

I am trying to sync data between an Ubuntu instance and a CentOS 7 instance. It's like a bi-directional rsync so I thought unison would be the best tool. I installed it on both instances but when I tried to connect them I received an error because the versions are different:

unison -testServer . ssh://myuser@myremotehost/efs/home/
Contacting server...
myuser@myremotehost's password:
Fatal error: Received unexpected header from the server:
 expected "Unison 2.48\n" but received "Unison 2.40\n\000\000\000\000\017",
which differs at "Unison 2.40".
This can happen because you have different versions of Unison
installed on the client and server machines, or because
your connection is failing and somebody is printing an error
message, or because your remote login shell is printing
something itself before starting Unison.

So I tried to make the versions match but when I look I only see the one version available on Ubuntu.

myuser@mylocalhost:/nas/$ apt policy unison
unison:
  Installed: 2.48.4-1ubuntu1
  Candidate: 2.48.4-1ubuntu1
  Version table:
 *** 2.48.4-1ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status

And when I look on CentOS 7 I don't see any versions

$ yum --showduplicates list unison
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: d36uatko69830t.cloudfront.net
 * epel: mirror.prgmr.com
 * extras: d36uatko69830t.cloudfront.net
 * updates: d36uatko69830t.cloudfront.net
Error: No matching Packages to list

However, I can install it with no problem:

$ sudo yum install unison
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: d36uatko69830t.cloudfront.net
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: d36uatko69830t.cloudfront.net
 * updates: d36uatko69830t.cloudfront.net
Package unison240-gtk-2.40.128-5.el7.x86_64 already installed and latest version
Nothing to do

Am I doing something wrong with finding the versions? How can I make them match?

The local host is:

myuser@mylocalhost:/nas$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04

The remote host is:

$ cat /etc/*release
CentOS Linux release 7.6.1810 (Core)

Best Answer

Per @Freddy's comment, the key is to compile unison from source on CentOS:

yum install ocaml ocaml-camlp4-devel ctags ctags-etags

cd ~
wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.4.tar.gz
tar xvfz unison-2.48.4.tar.gz
cd src
make

sudo cp -v unison /usr/local/sbin/
sudo cp -v unison /usr/bin/

cd ~
rm -fr src

Then you will be able to run unison:

On the local server, go to the desired location, then test it with

unison -testServer . ssh://myuser@myremotehost//path/to/data/

To do the real thing, simply remove -testServer from above. It's also a good idea to tmux before doing so.

Related Question