Lately there has been quite some publicity about privacy and security on the the public services hosting data. So I decided to minimize the Dropbox usage for file sync and go for locally hosted solution. It doesn't mean I'm out of dropbox, but rather I use it only for things I need to share outside my LAN.
My synchronization requirements
- two way sync
- non-interactive sync
- sync over ssh/local dirs (as pi works with ssh as a server out of the box)
- support for star topology - PC1..n (laptops) <-> Server (Raspberry Pi)
- keep additional dependencies to be installed on Raspberry low
- enable sync within LAN only (as I have quite some restricted internet connection with respect to data transfer quotas)
- operating on demand, rather than instantly (I want to use pi for other things as well and it's performance is not too impressive)
Alternative synchronization programsI checked briefly only following:
- quite popular and maintained,
- but not recommended for 2 way sync (as suggested on: )Two way sync with rsync.
- quite well known,
- but not actively developed any more, still patches seem to be applied from time to time.
- looks actively developed
- but compared to other 2 - eats more resources (on both sides, client and server)
Unison setup from scratch on PiI followed these steps:
- [on server] changed default raspberry password via:
- [on clients and the server] set up password-less authentication for ssh connection (following the howtoforge tutorial)
- [on clients and the server] installed unison:
sudo yum install unison
sudo apt-get install unison
- For Fedora:
- [on clients] setup unison with ssh as a synch protocol (following the howtoforge tutorial) with the custom unison preferences file (see next section for reference).
Custom setupI created new unison preferences file:
~/.unison/unison.prfthat has following contents:
# WATCH OUT: keep in sync across clients! # dirs root = /home/pb/unison root = ssh://email@example.com//media/My Book/pi/unison # Work silently batch = true auto=true times = true # logging log = true logfile = /home/pb/.unison/unison.log # Prevent deletion of all files if all files are locally deleted confirmbigdeletes = true # Check fast, don’t compare bit by bit fastcheck = true # "the default on Unix systems", see docs # ignore stuff ignore = Name *~ ## ignores all files with ~ (gedit backup files)Then I went for one more step. To synchronize via command line I issue following command on my client machines:
unison -ui text unisonTo make my life easier, I created in:
alias u-u="unison -ui text unison"So that I can simply initiate the synchronization with:
u-uThat's it for my setup. Please note the paths as well as server IP should be adapted in case you'd be using it.