diff options
Diffstat (limited to 'rdiff-backup')
-rw-r--r-- | rdiff-backup/excludes | 2 | ||||
-rw-r--r-- | rdiff-backup/rdiff-backup.inc.sh | 37 |
2 files changed, 39 insertions, 0 deletions
diff --git a/rdiff-backup/excludes b/rdiff-backup/excludes new file mode 100644 index 0000000..dc2af4a --- /dev/null +++ b/rdiff-backup/excludes @@ -0,0 +1,2 @@ +**/cache/** +**_scache.pag.* diff --git a/rdiff-backup/rdiff-backup.inc.sh b/rdiff-backup/rdiff-backup.inc.sh new file mode 100644 index 0000000..9af5484 --- /dev/null +++ b/rdiff-backup/rdiff-backup.inc.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Usage: Include this file, and add lines below lines like these: + +#rdiffit xayide.jones.dk /etc /home/jonas/websites +#rdiffit coreander.bitbase.dk /etc /home +#rdiffit ida.idaskolen.dk "(10000,10000)" /home + + + +function rdiffit() { + host="$1"; shift + + # grab optional upload and download limits + up=""; down="" + if echo "$1" | grep -Eq '^\(.*\)$'; then + updown=`echo "$1" | sed -e 's/^(\(.*\))$/\1/'` + up=`echo "$updown" | awk -F, '{ print $1 }'` + down=`echo "$updown" | awk -F, '{ print $2 }'` + shift + fi + for dir in $@; do + if echo "$dir" | grep -Eq '^/'; then + dir=`echo "$dir" | sed -e 's/^\///'` + else + echo "ERROR: host \"$host\" path \"$dir\" lacks leading \"/\"" + continue + fi + if [ "$host" = "`hostname -f`" ]; then + rdiff-backup --exclude '**/cache/**' --exclude '**_scache.pag.*' --exclude '**/mail/.imap/**' --exclude '**/jonas/src/**' --exclude '**/pc/downloads/**' /"$dir" "/var/local/backups/$host/rdiff-backup/${dir//\//-}" + elif [ -z "$up$down" ]; then + rdiff-backup --exclude '**/cache/**' --exclude '**_scache.pag.*' --exclude '**/mail/.imap/**' --exclude '**/jonas/src/**' --exclude '**/pc/downloads/**' --remote-schema 'ssh -o BatchMode=yes %s '\''rdiff-backup --server'\' $host::/"$dir" "/var/local/backups/$host/rdiff-backup/${dir//\//-}" + else + rdiff-backup --exclude '**/cache/**' --exclude '**_scache.pag.*' --exclude '**/mail/.imap/**' --exclude '**/jonas/src/**' --exclude '**/pc/downloads/**' --remote-schema 'cstream -t '$up' | ssh -o BatchMode=yes %s '\''rdiff-backup --server'\'' | cstream -t '$down $host::/"$dir" "/var/local/backups/$host/rdiff-backup/${dir//\//-}" + fi + done +} |