Bash Inotify Rsync = birsync!
birsync
uses Linux's inotify facility to detect file and folder changes in a watched directory. When a change is detected, birsync spawns an rsync process to sync those changes to a desired server, respecting your bandwidth, and never running more than one instance of rsync at a time.
birsync
should run on most Linux platforms, including embedded devices. As long as you can get inotifywait
(part of inotify-tools) on your platform (ie. ipkg, optware), it should work.
Tested on QNAP NAS to sync an FTP root securely to a cloud server, since FTP on the open Internet is bad.
- watches for changes in files and directories
- recursively adds directories created in watched directories
- ensures only one rsync runs at a time
- bandwidth limiting (an rsync feature)
- Embedded device compatibility
- Bash 3/4 compatible
- minimal subshells spawned (this is costly)
- logfile management
-
change variables in script according to your needs, particularly
watcheddir=
andrsyncdest=
. -
Set up SSH pubkey auth (passwordless) between your client and the destination
-
run it!
$ ./birsync
- check
birsync-error.log
,birsync-sync.log
andbirsync-changes.log
for clues - make sure
lockfile
is baleeted ifrsync
really is not running