Unison ==================================================================================== What is Unison? ----------------------------------------------------------------------------------------------------------------------------------------------- Install Unison Unison will need to be installed on both servers that are sharing files. RHEL: yum install unison Debian: apt install unison ----------------------------------------------------------------------------------------------------------------------------------------------- Configuration of unison Before configuring unison itself, you need to ensure that the hosts have shared keys (since this connection is made via SSH). ssh-keygen -t rsa ssh-copy-id root@otherserver Once that's sorted, the unison service itself can be configured. default unison config file: /root/.unison/default.prf root = / root = ssh://b4sed-01// path = var/spool/cron/ path = etc/passwd path = etc/shadow path = etc/group path = etc/motd path = etc/drbd.conf path = etc/cluster/cluster.conf path = etc/php.ini path = etc/nginx/ ignore = Name access.log* To have unison run automatically, you'll need to configure a cron: vi /usr/local/bin/sync.sh Contents of the file (the SISTER= value needs to be updated). #!/bin/bash SISTER=ABC-WEBDB-01 [ -f /var/run/file_sync.pid ] && exit 1; trap "{ rm /var/run/file_sync.pid; exit; }" EXIT; trap "{ echo 'Bailing out!' 1>&2 ssh -T -p2020 root@$SISTER <<<'killall unison; exit' &>/dev/null }" KILL ABRT INT TERM HUP SEGV touch /var/run/file_sync.pid /usr/bin/unison -sshargs "-p 2020" -batch -terse -silent -owner -group -numericids -prefer / Once added, then the cron needs setting up crontab -e * * * * * /usr/local/bin/sync.sh > /root/.unison/unison.log You would then need to add a cron on the 2nd server, you'll need to add this with the '-prefer' omitted, as below: #!/bin/bash SISTER=ABC-WEBDB-01 [ -f /var/run/file_sync.pid ] && exit 1; trap "{ rm /var/run/file_sync.pid; exit; }" EXIT; trap "{ echo 'Bailing out!' 1>&2 ssh -T -p2020 root@$SISTER <<<'killall unison; exit' &>/dev/null }" KILL ABRT INT TERM HUP SEGV touch /var/run/file_sync.pid /usr/bin/unison -sshargs "-p 2020" -batch -terse -silent -owner -group -numericids / ==================================================================================== Multi-server (2+) Unison setup To preface this; Advanced Unison topologies such as the one I detail on this page aren't ideal, one reason for this is that any change requires that unison be run bidirectionally for each node - meaning that synchronisation is definitely not instant. Depending on the content type, a better option might be to have an NFS Share configured. There are different methods that can be used to setup Unison when more than 2 servers are installed, for example, ring and star topology. In this example, I've focussed on the star topology: To set the context for this example and give some explanation; This setup consists of 6 servers, with 1 of those servers acting as the 'master' - being the middle of the star. Unison should be configured on only the master node, from here, you'll need to configure the .prf files and alter the Unison cronjob script accordingly. ------------------------------------------------------------------------------------------------------------------------------------------------ Configuration 1. Install Unison on the master node Decide which node is going to be the master, and install Unison on there. 2.  ====================================================================================