david 5d14c57836 | ||
---|---|---|
.gitignore | ||
README.md | ||
sshbackup |
README.md
sshbackup
sshbackup is a shell script for doing incremental backups. it creates as many incremental versions of a folder as you wish for and it does that with local folders as well as with remote folders.
installation
sudo wget https://raw.github.com/beyondthewall/sshbackup/0.3/sshbackup -O /usr/bin/sshbackup
sudo chmod +x /usr/bin/sshbackup
usage
"usage: sshbackup <options> source destination [versions]"
"source/destination example: [[user@]server:]/path/to/files"
"OPTIONS:"
-h, --help show this message"
-v, --version version information"
-c, --config <file> alternate config file [~/.sshbackup]"
-l, --list <file> list of sources and destinations"
-s, --sshkey <file> alternate sshkey [~/.ssh/id_rsa]"
scheduling
using cronjobs is the way to go. example /etc/crontab:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO="admin@example.com"
#m h dom mon dow user command
0 2 * * * root sshbackup /path/to/source /path/to/destination 5
0 3 * * * root sshbackup -s /path/to/sshkey -l /path/to/listfile
0 4 * * * root sshbackup bkpuser@server:/path/to/source /path/to/destination 30
notifications
utilize crons MAILTO directive for getting error notifications.
MAILTO=admin@example.com
automation
for automated backups configure a sshkey for the root user and configure your remote machines to trust that key.
sudo su
ssh-keygen
ssh-copy-id <remote machine>
you must add the backupuser to /etc/sudoers on your remote servers as well to make automated backups work. type:
sudo visudo #this will open /etc/sudoers in a texteditor
and add following at the end of that file:
backupuser ALL=(root)NOPASSWD: /usr/bin/rsync
you can use a file which should have a source/destination combination each line. example listfile:
#<source> <destination> [<versions>]
david@dev.socialnerds.org:/home/david /home/david/Downloads/devhome 30
backupuser@dev.socialnerds.org:/home/gollum/ /home/david/Downloads/gollum
/home/david/something /home/david/backup 5
~/.sshbackup
an example config for default values looks like this [optional]:
#rsync options.
rsyncoptions="-pogEthrzl --numeric-ids --no-motd"
#dotglob option removes bug while rsyncing folder with no visible files in it.
remotecmd="shopt -s dotglob; /usr/bin/sudo /usr/bin/rsync"
localcmd="/usr/bin/rsync"
sshkeyfile="$HOME/.ssh/id_rsa"
future features
- notification on errors (with cron for now)
- useful logging
- remote settings deployment
- bandwidth limits
- sshkey creation/management
- some kind of optional reports/stats
- install missing dependencies