How to sync directories between several computers
Par Luciol
How to sync my home directories between my personnal computers
-
Use case : let’s assume you have at least two pc’s, with personnal files in a home directory, and would like to have the same versions of your files on both computers. Your systems can communicate by ssh.
-
Solution : synchronize your files with unison (cross platform solution).
-
How to (very short) :
-
Install unison : with apt if under a debian like distrib. Otherwise, refer to you operating system packages manager. Bonus, unison was also available on windows.
sudo apt get install unison
Pay attention to the unison version : not all are compatible between them. The installation process might be developped more precisely in a further version of this post.
-
Choose the directory you want to sync. Since unison will browse every file before syncing (to determine wich is the most recent one), it can be a very long process if you try to sync .cache directories, or very large files accross the network.
-
Sync with the propers options : for exemple
unison -auto -perms 0 ~/myLocalDir ssh://me@remotepc//home/me/myDistantDir/
Explanations :
- auto : reconcile changes automaticaly (otherwise you will be asked for each - … each what… I should check).
- perms 0 : don’t touch file permissions (linux). Otherwise it will mess the rights between the two systems.
- me : the user (you)
- myLocal[Distant]Dir : self explanatory.
-