X-Git-Url: http://git.hcoop.net/clinton/scripts.git/blobdiff_plain/bc16fd9e951108bf9ddbee92f9bc5b35878d1e59..f1a20ec86444a5b8185908c0262037de7e2e286a:/hcoop-backup diff --git a/hcoop-backup b/hcoop-backup index 366efef..d771434 100755 --- a/hcoop-backup +++ b/hcoop-backup @@ -8,8 +8,6 @@ # run this script as root, on deleuze # -exec >& /var/log/backup-to-s3-log - PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin #COMPRESS_EXT=.bz2 #COMPRESS_PROG=bzip2 @@ -17,14 +15,18 @@ COMPRESS_EXT=.gz COMPRESS_PROG=gzip KEYFILE=/etc/backup-encryption-key BACKUPTMP=/var/backups/hcoop-backup -CURDATE=$(date +%Y.%m.%d) +CURDATE=$(date -u +%Y.%m.%d) -MOVE_OVER=$(dirname $0)/s3-move +MOVE_OVER=$(dirname $0)/rsync.net-move-over IFS=$'\n' -#prune_old_backups +# Initialize storage area +RSYNCDIR=/vicepa/hcoop-backups/files +rm -fr $RSYNCDIR +mkdir -p $RSYNCDIR/$CURDATE +# Initialize backup staging area mkdir -p $BACKUPTMP cd $BACKUPTMP @@ -88,7 +90,7 @@ cat backupfiles | \ grep -v ^/vmlinuz | \ grep -v ^/vmlinuz.old | \ grep -v '^/sbin/[a-z\-]*\.modutils$' | \ - grep -v ^/opt/dell/srvadmin/ | \ + grep -v ^/opt | \ grep -v ^/boot/ | \ grep -v ^/dev/ | \ grep -v ^/etc/ | \ @@ -145,11 +147,11 @@ vos listvol deleuze | \ cat volumes | \ grep -v not-backed-up | \ xargs -I{} -d\\n -- \ - bash -c \ + bash -e -c \ "F={}.dump$COMPRESS_EXT.aescrypt ; vos dump -id {} -localauth -clone | $COMPRESS_PROG | ccrypt -k $KEYFILE -e | - $MOVE_OVER $CURDATE \$F" + $MOVE_OVER $CURDATE \$F" || : echo "Backing up databases ..." F=databases.tar$COMPRESS_EXT.aescrypt @@ -158,6 +160,12 @@ tar -C /var/backups/databases/ -cf - . | \ ccrypt -k $KEYFILE -e | \ $MOVE_OVER $CURDATE $F +# Update file permissions so that rsync.net can access the backups +chmod -R go=,u-w $RSYNCDIR +chmod u+w $RSYNCDIR +chown -R rsync $RSYNCDIR + +# Complain to admins if there are unknown files grep '[a-z/]' complain && \ mail -a 'From: The Backup Program ' \ -s "automated message: annoying files found on deleuze (please do something about them)" admins@hcoop.net \