From 3b16fa867a36f38b2032b8f49c8725f6ac711418 Mon Sep 17 00:00:00 2001 From: mwolson_admin Date: Wed, 25 Jun 2008 04:15:45 -0400 Subject: [PATCH] hcoop-backup: Keep track of date. - Also, locase the local variable names. --- hcoop-backup | 9 +++++---- s3.common | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hcoop-backup b/hcoop-backup index 39fb266..934c257 100755 --- a/hcoop-backup +++ b/hcoop-backup @@ -17,6 +17,7 @@ COMPRESS_EXT=.gz COMPRESS_PROG=gzip KEYFILE=/etc/backup-encryption-key BACKUPTMP=/var/backups/hcoop-backup-testing +CURDATE=$(date +%Y.%m.%d) MOVE_OVER=$(dirname $0)/s3-move @@ -105,7 +106,7 @@ F=hcoop.backup.tar$COMPRESS_EXT.aescrypt tar clpf - --ignore-failed-read --no-recursion -C / -T backupfiles | \ $COMPRESS_PROG | \ ccrypt -k $KEYFILE -e | \ - $MOVE_OVER $F + $MOVE_OVER $CURDATE $F # Acquire lock before messing with spamd COUNT=0 @@ -128,7 +129,7 @@ tar clpf - --ignore-failed-read -C / /var/local/lib/spamd | \ $COMPRESS_PROG | \ ccrypt -k $KEYFILE -e > $F rm -f $LOCK -< $F $MOVE_OVER $F +< $F $MOVE_OVER $CURDATE $F rm -f $F vos listvol deleuze | \ @@ -149,14 +150,14 @@ cat volumes | \ "F={}.dump$COMPRESS_EXT.aescrypt ; vos dump -id {} -localauth -clone | $COMPRESS_PROG | ccrypt -k $KEYFILE -e | - $MOVE_OVER \$F" + $MOVE_OVER $CURDATE \$F" echo backing up databases F=databases.tar$COMPRESS_EXT.aescrypt tar -C /var/backups/databases/ -cf - . | \ $COMPRESS_PROG | \ ccrypt -k $KEYFILE -e | \ - $MOVE_OVER $F + $MOVE_OVER $CURDATE $F grep '[a-z/]' complain && \ mail -a 'From: The Backup Program ' \ diff --git a/s3.common b/s3.common index 09d1e77..01a4497 100644 --- a/s3.common +++ b/s3.common @@ -7,7 +7,6 @@ CHUNKSIZE=5000 BUCKET=hcoop.net-backups BACKUPDIR=full -SUBDIR=$(date +%Y.%m.%d) S3CMD=$(dirname $0)/s3 IFS=$'\n' @@ -33,19 +32,22 @@ function s3_cmd () { function move_over () { # Move file to its offsite destination. # Expects the file to come from STDIN. - # $1: filename, $2: relative directory (optional) - if test -z "$1" || test -n "$3"; then + # $1: date subdirectory + # $2: filename + # $3: relative directory (optional) + if test -z "$2" || test -n "$4"; then echo "Bad programming" exit 1 fi - local FILE=$1 - local DEST=$BACKUPDIR/$SUBDIR + local subdir=$1 + local file=$2 + local dest=$BACKUPDIR/$subdir if test -n "$2"; then - DEST=$DEST/$2 + dest=$dest/$2 fi - split -d -b ${CHUNKSIZE}m - ${FILE}. - for i in ${FILE}.*; do - s3_cmd put $DEST/$i $i + split -d -b ${CHUNKSIZE}m - ${file}. + for i in ${file}.*; do + s3_cmd put $dest/$i $i rm -f $i done } @@ -53,6 +55,7 @@ function move_over () { function prune_old_backups () { # Implement me + local subdir=$1 local oldpwd=$PWD cd $BACKUPDIR find . -mindepth 1 -maxdepth 1 -type d -ctime +7 \ -- 2.20.1