david/sshbackup
david
/
sshbackup
Archived
1
0
Fork 0
This repository has been archived on 2023-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
sshbackup/README.md

72 lines
2.0 KiB
Markdown
Raw Normal View History

2013-04-27 22:49:03 +02:00
# sshbackup
2013-04-27 22:55:18 +02:00
sshbackup is a shell script for doing incremental backups.
2013-04-27 22:43:01 +02:00
2013-04-27 22:49:03 +02:00
### scheduling
2013-04-27 22:43:01 +02:00
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:49:03 +02:00
### notifications
2013-04-27 22:43:01 +02:00
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
2013-04-27 22:49:03 +02:00
### automation
2013-04-27 22:43:01 +02:00
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>
```
2013-04-27 22:55:18 +02:00
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
```
2013-04-27 22:43:01 +02:00
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
2013-04-27 22:49:03 +02:00
### ~/.sshbackup
2013-04-27 22:43:01 +02:00
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"
```
2013-04-27 22:49:03 +02:00
### future features
2013-04-27 22:43:01 +02:00
- [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