david/sshbackup
david
/
sshbackup
Archived
1
0
Fork 0
bash script for performing incremental backups.
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.
Go to file
david c9a32d3899 Update README.md 2016-05-05 23:01:40 +02:00
LICENSE Added license 2015-11-12 19:44:37 +01:00
README.md Update README.md 2016-05-05 23:01:40 +02:00
sshbackup some final changes to oh_four 2013-07-07 20:09:55 +02:00

README.md

sshbackup

sshbackup is a bash 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://socialg.it/scripts/sshbackup/raw/master/sshbackup -O /usr/bin/sshbackup
sudo chmod +x /usr/bin/sshbackup

usage

usage: sshbackup <options> [[user@]server:]/source/path /destination/path [versions]

OPTIONS:
   -h, --help                show this message
   -v, --version             version information

   -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

   -d, --deploy              deploy settings to remote host
   -n, --no-root             run without root privileges

scheduling

for doing reoccuring backups utilize cron to do the job. type:

sudo crontab -e

and create cronjob(s) like following:

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   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

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

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)

listfile

you can use a listfile (-l|--list) 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 with default values looks like this.

#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"
#default versions
versions=999

roadmap

this should be a little overview of what's coming..

.
.
.                    
|
|
+--- version 0.3.1
|
+--- better error output
+--- check missing dependencies
+--- automatic sshkey creation
+--- bandwidth limits
+--- remote settings deployment
+--- move documentation to sudo crontab -e
+--- root privileges optional
|
+--- version 0.4.0
|                    O/
|                   /|
+--- You are here   / \
|
+--- install missing dependencies automatically
+--- check if process is still running
|
+--- version 0.4.1
.
.
.

(roadmap is inspired by https://github.com/hbons/SparkleShare/wiki/Roadmap)