rsyncbackup

#!/bin/bash

# rsyncbackup
#
# Tom Wizetek <tom@wizetek.com>
# 2012-04-12
#
# based on https://wiki.archlinux.org/index.php/Full_System_Backup_with_rsync

[[ $UID != 0 ]] && echo "$(basename $0): must run as root. Trying to sudo now..." && exec sudo $0 $@

REMOTE="filer"
TARGET="/BACKUPS/$HOSTNAME/"
FILTER="
; Include
+ /dev/console
+ /dev/null
+ /dev/zero
+ /dev/initctl

; Exclude
- /dev/*
- /proc/*
- /sys/*
- /run/*
- /tmp/*
- /mnt/*
- /media/*
- /var/cache/*
- /var/abs/*
- **/.gvfs/
- **/lost+found/
"

[[ $HOSTNAME != $REMOTE ]] && TRANSPORT="-e ssh" && DESTINATION="root@$REMOTE:" && TIMESTAMP="ssh root@$REMOTE"

echo "$(date +%T) Starting sync - wait..."

echo "$FILTER" | rsync $TRANSPORT -aHAXS
--exclude-from=- --delete-after --delete-excluded --numeric-ids --ignore-errors $@ / ${DESTINATION}${TARGET}
$TIMESTAMP touch $TARGET

echo "$(date +%T) Done."