Syncing files with unison: Difference between revisions
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
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. | 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. | ||
'''First follow the [ | '''First follow the [[SSH_HowTo| SSH how to]] to set up a direct connection between your LWP and your other computer(s)''' | ||
1. Install the Unison package (on Debian based systems) | 1. Install the Unison package (on Debian based systems) | ||
apt-get install unison | sudo apt-get install unison | ||
2. Configure the Unison defaults (EDIT ~/.unison/default.prf) | 2. Configure the Unison defaults (EDIT ~/.unison/default.prf) |
Latest revision as of 10:06, 28 August 2023
Installing and configuring Unison File Synchronizer
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.
First follow the SSH how to to set up a direct connection between your LWP and your other computer(s)
1. Install the Unison package (on Debian based systems)
sudo apt-get install unison
2. Configure the Unison defaults (EDIT ~/.unison/default.prf)
# skip asking for confirmations on non-conflicting changes auto=true # the user interface will ask no questions at all batch=true # Unison will request an extra confirmation if it appears that the entire replica has been deleted confirmbigdeletes=true # 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$ fastcheck=true # the group attributes of the files are synchronized group=true # the owner attributes of the files are synchronized owner=true # prefer newer version of files in case of conflicts prefer=newer # the textual user interface will print nothing at all, except in the case of errors. silent=true # file modification times (but not directory modtimes) are propagated. times=true
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.
5. Manually synchronize a directory
unison ~/<dir> ssh://PC-Work.fac.rug.nl//~/<dir>
This will sync ~/<dir> between the local machine and PC-Work.fac.rug.nl
6. Automatically synchronize every 5 minutes using crontab (crontab -e)
*/5 * * * * unison ~/<dir> ssh://PC-Work.fac.rug.nl//~/<dir> &> /dev/null