In this tutorial we’ll install the Debian Linux 9 (squeeze), Apache 2 with mpm-itk (to run each web as a isolated user),...
Installing and configuring Unison File SynchronizerÁstþór IP
Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.
1. Install the Unison package
apt-get install unison
2. Configure the Unison defaults (pico /root/.unison/default.prf)
# skip asking for confirmations on non-conflicting changes
# the user interface will ask no questions at all
# Unison will request an extra confirmation if it appears that the entire replica has been deleted
# Unison will use the modification time and length of a file as a `pseudo inode number' when scanning replicas for updates, instead of reading the full cont$
# the group attributes of the files are synchronized
# the owner attributes of the files are synchronized
# prefer newer version of files in case of conflicts
# the textual user interface will print nothing at all, except in the case of errors.
# file modification times (but not directory modtimes) are propagated.
A few of the configuration values will make Unsion silent so that no user action will be required to do the sync, deleted files will be moved to /var/backups/unison to avoid accidental deletion and if the same file is updated on both servers we’ll keep the newer file.
3. Create a private key to avoid passphrase popup to be able to do automatic synchronization
ssh-keygen -t dsa
4. Copy the key to the remote machine
ssh-copy-id -i .ssh/id_dsa.pub [email protected]
5. Manually synchronize a directory
unison /var/www ssh://remote.machine.com//var/www
This will sync /var/www between the local machine and remote.machine.com
6. Automatically synchronize every 5 minutes using crontab (crontab -e)
*/5 * * * * unison /var/www ssh://remote.machine.com//var/www &> /dev/null