2013-04-26 11:00:09 +02:00
|
|
|
sshbackup
|
|
|
|
=========
|
2012-08-27 11:13:24 +02:00
|
|
|
|
2013-04-27 21:00:51 +02:00
|
|
|
for automated backups configure a sshkey for the user running sshbackup.
|
|
|
|
|
|
|
|
you must add following to /etc/sudoers on your remote servers as well to
|
|
|
|
make automated backups work
|
|
|
|
```backupuser ALL=(root)NOPASSWD: /usr/bin/rsync```
|
|
|
|
|
2013-04-27 22:43:01 +02:00
|
|
|
|
|
|
|
scheduling
|
|
|
|
----------
|
|
|
|
using cron will help you with that. example /etc/crontab:
|
2013-04-27 21:00:51 +02:00
|
|
|
```
|
2013-04-27 22:43:01 +02:00
|
|
|
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
|
2013-04-27 21:00:51 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2013-04-27 22:43:01 +02:00
|
|
|
notifications
|
|
|
|
-------------
|
|
|
|
utilize crons MAILTO directive for getting error notifications.
|
2013-04-27 22:44:45 +02:00
|
|
|
```
|
|
|
|
MAILTO=admin@example.com
|
|
|
|
```
|
2013-04-27 22:43:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
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 can use a file which should have a source/destination combination each line.
|
|
|
|
example listfile:
|
2013-04-27 21:00:51 +02:00
|
|
|
```
|
2013-04-27 22:43:01 +02:00
|
|
|
#<source> <destination> [<versions>]
|
2013-04-27 21:00:51 +02:00
|
|
|
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
|
|
|
|
```
|
2013-04-27 22:43:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
~/.sshbackup
|
|
|
|
------------
|
|
|
|
a 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
|
|
|
|
---------------
|
|
|
|
- [x] 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
|