To get Unison running first set up passwordless SSH authentication between the two hosts you want to sync. Then update the default Unison configuration file which can be found at /root/.unison/default.prf.
A simple configuration file to synchronize the /var/www/www.domain1.com and /var/www/www.domain2.com folder would look like this.
Unison preferences file # Set the source and destination folder that should be synced root = /var/www/ root = ssh://email@example.com//var/www/ # If you only want to sync specific subfolders specify them here # If you want to sync the full root folder, delete the path lines path = www.domain1.com/ path = www.domain2.com/ # Enable to run Unison silently in the background batch = true
Test the configuration by running the command unison in the terminal. To automatically sync the folders every two minutes add a cronjob like
*/2 * * * * /usr/bin/unison &> /dev/null