csbackup — csbackup
csbackup [-s | --setup] [-k | --keys ] [-e | --etc ] [-c | --crontab] [-l | --logfile FILE] [-i | --inside-cs] [-m | --mailremainder EMAIL]
csbackup is a wrapper around rsync written in bash to sync files to a file server with some nice extra goodies to make life easier.
Features:
Before first use, you should do some setup:
After you have edited $HOME/.csbackuprc, run csbackup manually a second time, now using the command csbackup --setup. This will do two things:
For security reasons, you might want to disable shell login with the ssh key pair (it has an empty passphrase!) and only allow rsync connections. To this end, you can do the following ON THE FILE SERVER:
Create a file $HOME/bin/validate-rsync.sh with contents:
#!/bin/sh case "$SSH_ORIGINAL_COMMAND" in *\&*) echo "Rejected" ;; *\;*) echo "Rejected" ;; rsync\ --server*) $SSH_ORIGINAL_COMMAND ;; *) echo "Rejected" ;; esac
Make this file executable:
chmod +x $HOME/bin/validate-rsync.sh
Edit the file $HOME/.ssh/authorized_keys, adding a prefix command="…" to the line containing the public key used for the backup. The result should be of the form:
command="$HOME/bin/validate-rsync.sh",no-pty,no-port-forwarding,no-agent-forwarding,no-X11-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+v4aFa7CgxlQCjyl/P1iF4AGTN3UJaW+iPQsyGJdSap0nR4Wzz9m/U2fOUJxEIOqFlyFd2V/eDHwEjYscKu767ascNOkF2kiagsRDcywn0KuFe++8DPoNttkvfxsWuKnsKXfJMI9Wl6jH5/8yQD6uOBJXvQz+OSe6HeFT/QJGIcIf2uqLEJFr6tkVAHTkaMe+RcrHXAS0/Ej64IOZbLQwlyIQOyS1+XDUkW6V04muapwBSdzlrfyLPa39GeG4YoSFpWHi3DWJs1oxYArfgr61xJEZ/jIY3brhtmY1NcHB3gbreSklLcILlgkjYIMsLlz8CivxgTk1vM53iAsPttRtQ== yves@dirac
Initial setup before first use:
csbackup vi $HOME/.csbackuprc csbackup --setup
To setup a daily cronjob that only runs when inside the CS domain and writes a log to a file, you should run:
csbackup --cronjob --logfile $HOME/.csbackup.log --inside-cs
You can always manually edit the created job via the command
crontab -e
Setup an email reminder that checks every day at 00:00 if the last successful backup is older than 7 days:
csbackup --mailremainder yves.frederix@cs.kuleuven.be
To fine tune (e.g., to use a different grace period), edit the cron job on the file server:
ssh <fileserver> crontab -e
Backup with inclusion of the files in /etc:
csbackup --etc
Specific files in a directory can be excluded by adding a file with name ‘.NoCsBack’. E.g., to exclude the files (or directories) ‘test1’, you would create a file ‘.NoCsBack’ with contents:
- test1
This file follows the syntax for rsync filter rules (see also the rsync man page).