Dropbox-like synchronization for Linux
One of the requirement for load-balancing servers is server file need to be synchronized. Otherwise, part of your visitors can see your new WordPress post but won’t be able to see the attached photos. rsync
can’t do the job properly, because any synchronization tool need to look at the previous state of files in order to determine if new files have been added or any file has been changed or deleted. Fortunately there are several tool:
-
BittorrentSync: This is a fully automatic solution, and as close to Dropbox as possible. You just need to download
btsync
, generate directory private key and input it into another instance in the other server. Done. -
Unison: This program run on top of rsync as default (but you can change it), but you need a little trick in order to run it properly. My favorite command is:
unison -batch -prefer newer -silent -owner -group -times -perms 777 //dir1 //dir2
The meaning of this command is:
- -batch: Run in batch mode without asking confirmation
- -prefer newer: Prefer newer file if conflict
- -owner: Preserve owner information
- -group: Preserve group information
- -times: Preserve time
- -perms 777: Preserve permission
That’s it. If you know any other tool, let me know in the comment section. Happy sync’ing!