blob: 96877e879f71277d1c8f23078d82ed88a2550f42 (
plain)
- #!/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.idraetsdaghojskolen.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
- excludes=""
- while read exclude; do
- excludes="$excludes --exclude $exclude"
- done < /etc/local-COMMON/rdiff-backup/excludes
- if [ "$host" = "`hostname -f`" ]; then
- rdiff-backup --terminal-verbosity 1 $excludes /"$dir" "/var/local/backups/$host/rdiff-backup/${dir//\//-}"
- elif [ -z "$up$down" ]; then
- rdiff-backup --terminal-verbosity 1 $excludes --remote-schema 'ssh -o BatchMode=yes %s '\''rdiff-backup --server'\' $host::/"$dir" "/var/local/backups/$host/rdiff-backup/${dir//\//-}"
- else
- rdiff-backup --terminal-verbosity 1 $excludes --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
- }
|