summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff-backup.inc.sh
blob: 9af54842684020d9c9918756a28c0528469ed450 (plain)
  1. #!/bin/bash
  2. # Usage: Include this file, and add lines below lines like these:
  3. #rdiffit xayide.jones.dk /etc /home/jonas/websites
  4. #rdiffit coreander.bitbase.dk /etc /home
  5. #rdiffit ida.idaskolen.dk "(10000,10000)" /home
  6. function rdiffit() {
  7. host="$1"; shift
  8. # grab optional upload and download limits
  9. up=""; down=""
  10. if echo "$1" | grep -Eq '^\(.*\)$'; then
  11. updown=`echo "$1" | sed -e 's/^(\(.*\))$/\1/'`
  12. up=`echo "$updown" | awk -F, '{ print $1 }'`
  13. down=`echo "$updown" | awk -F, '{ print $2 }'`
  14. shift
  15. fi
  16. for dir in $@; do
  17. if echo "$dir" | grep -Eq '^/'; then
  18. dir=`echo "$dir" | sed -e 's/^\///'`
  19. else
  20. echo "ERROR: host \"$host\" path \"$dir\" lacks leading \"/\""
  21. continue
  22. fi
  23. if [ "$host" = "`hostname -f`" ]; then
  24. rdiff-backup --exclude '**/cache/**' --exclude '**_scache.pag.*' --exclude '**/mail/.imap/**' --exclude '**/jonas/src/**' --exclude '**/pc/downloads/**' /"$dir" "/var/local/backups/$host/rdiff-backup/${dir//\//-}"
  25. elif [ -z "$up$down" ]; then
  26. 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//\//-}"
  27. else
  28. 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//\//-}"
  29. fi
  30. done
  31. }