#! /bin/sh # safe-rsync-daemon (Bourne shell script) -- invokes rsync as a "one-off" i.e. non-listening daemon # Inspired by http://utcc.utoronto.ca/~cks/space/blog/sysadmin/RsyncReplicationSetup # # Example .ssh/authorized_keys entry for a client host called "hedgehog": # command="/usr/local/bin/safe-rsync-daemon hedgehog",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty [...] # see /usr/include/sysexits.h readonly EX_USAGE=64 readonly EX_NOINPUT=66 readonly EX_OSFILE=72 readonly EX_CONFIG=78 # check parameters test -n "$1" || exit $EX_USAGE client=$1 dir=/srv/backup/clients/$client conf=/srv/backup/rsyncd_conf/$client.conf # No point testing for these since the sender won't see the exit code and will # instead detect a protocol error. So let rsync test for them. ## # check for target directory ## test -d $dir || exit $EX_NOINPUT ## ## # check for rsync daemon-mode configuration file ## # TO-DO: validate it ## test -r $conf || exit $EX_CONFIG exec /usr/bin/rsync --server --daemon --config=$conf .