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

134 lines
3.5 KiB
Markdown
Raw Permalink Normal View History

2013-04-27 22:49:03 +02:00
# sshbackup
2013-04-28 16:00:22 +02:00
sshbackup is a bash script for doing incremental backups.
2013-04-28 00:19:51 +02:00
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
```sh
2016-05-05 23:01:40 +02:00
sudo wget https://socialg.it/scripts/sshbackup/raw/master/sshbackup -O /usr/bin/sshbackup
2013-04-28 00:19:51 +02:00
sudo chmod +x /usr/bin/sshbackup
```
### usage
2013-06-29 15:34:49 +02:00
```text
2013-07-07 20:09:55 +02:00
usage: sshbackup <options> [[user@]server:]/source/path /destination/path [versions]
2013-04-28 00:19:51 +02:00
2013-07-07 09:57:45 +02:00
OPTIONS:
-h, --help show this message
-v, --version version information
2013-04-28 00:19:51 +02:00
2013-07-07 09:57:45 +02:00
-l, --list <file> list of sources and destinations
-c, --config <file> alternate config file [~/.sshbackup]
-s, --sshkey <file> alternate sshkey [~/.ssh/id_rsa]
-b, --bandwidth <kbps> bandwidth limit in kbit/s
2013-07-07 20:09:55 +02:00
-d, --deploy deploy settings to remote host
2013-07-07 09:57:45 +02:00
-n, --no-root run without root privileges
2013-04-28 00:19:51 +02:00
```
2013-04-27 22:43:01 +02:00
2013-04-27 22:49:03 +02:00
### scheduling
2013-07-01 21:24:34 +02:00
for doing reoccuring backups utilize cron to do the job. type:
```sh
sudo crontab -e
```
and create cronjob(s) like following:
2013-06-29 15:35:07 +02:00
```text
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"
2013-06-29 22:41:05 +02:00
#m h dom mon dow command
0 2 * * * sshbackup /path/to/source /path/to/destination 5
0 3 * * * sshbackup -s /path/to/sshkey -l /path/to/listfile
0 4 * * * 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-06-29 15:36:38 +02:00
```text
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.
2013-06-29 15:36:38 +02:00
```sh
2013-04-27 22:43:01 +02:00
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:
2013-06-29 15:36:38 +02:00
```sh
2013-04-27 22:55:18 +02:00
sudo visudo #this will open /etc/sudoers in a texteditor
```
and add following at the end of that file:
2013-06-29 15:36:38 +02:00
```text
2013-04-27 22:55:18 +02:00
backupuser ALL=(root)NOPASSWD: /usr/bin/rsync
```
2013-07-07 20:36:40 +02:00
*all of this can be done by sshbackup automatically.*
(a key pair will be generated if none is found and for deploying remote settings use the --deploy switch)
2013-07-07 20:31:39 +02:00
2013-07-07 20:36:40 +02:00
### listfile
you can use a listfile (-l|--list) which should have a source/destination combination each line.
2013-04-27 22:43:01 +02:00
example listfile:
2013-06-29 15:36:38 +02:00
```text
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-07-01 22:41:05 +02:00
an example config with default values looks like this.
2013-06-29 15:36:38 +02:00
```text
2013-04-27 22:43:01 +02:00
#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-30 17:31:13 +02:00
#default versions
versions=999
2013-04-27 22:43:01 +02:00
```
2013-06-29 12:36:24 +02:00
2013-06-29 12:37:41 +02:00
### roadmap
2013-06-29 12:36:24 +02:00
this should be a little overview of what's coming..
```
.
.
.
|
|
+--- version 0.3.1
|
2013-07-07 20:31:39 +02:00
+--- better error output
+--- check missing dependencies
+--- automatic sshkey creation
2013-06-29 12:36:24 +02:00
+--- bandwidth limits
+--- remote settings deployment
+--- move documentation to sudo crontab -e
2013-07-07 20:31:39 +02:00
+--- root privileges optional
2013-06-29 12:36:24 +02:00
|
+--- version 0.4.0
2013-07-07 20:31:39 +02:00
| O/
| /|
+--- You are here / \
|
+--- install missing dependencies automatically
+--- check if process is still running
2013-06-29 12:36:24 +02:00
|
2013-07-07 20:31:39 +02:00
+--- version 0.4.1
2013-06-29 12:36:24 +02:00
.
.
.
```
_(roadmap is inspired by https://github.com/hbons/SparkleShare/wiki/Roadmap)_