-SCRIPTDIR=$(dirname $0)
-KEYFILE=/etc/backup-encryption-key
-BUCKET=hcoop.net-backups
-BACKUPDIR=full
-BACKUPTMP=/var/backups/hcoop-backup-testing
-SUBDIR=$(date +%Y.%m.%d)
-
-export S3_ACCESS_KEY_ID=$(cat ~mwolson_admin/.amazon/access.key)
-export S3_SECRET_ACCESS_KEY=~mwolson_admin/.amazon/secret.key
-
-function s3_cmd () {
- # $1: command (get|put|ls|rm)
- # $2: bucket
- # $3: destination
- # $4: source file
- $SCRIPTDIR/s3 $1 $2 $3 $4 ${BWLIMIT}K
-}
-
-function copy_over () {
- # Move file to its offsite destination
- # $1: file, $2: relative directory (optional)
- if test -z "$1" || test -n "$3"; then
- echo "Bad programming"
- exit 1
- fi
- local FILE=$1
- local DEST=$BACKUPDIR/$SUBDIR
- if test -n "$2"; then
- DEST=$DEST/$2
- fi
- s3_cmd put $BUCKET $DEST/$FILE $FILE
- rm -f $FILE
-}
-
-function prune_old_backups () {
- local oldpwd=$PWD
- cd $BACKUPDIR
- find . -mindepth 1 -maxdepth 1 -type d -ctime +7 \
- -execdir rm -fr '{}' \; || true
- rm -rf $SUBDIR
- mkdir -p $SUBDIR
- cd $oldpwd
-}
-
-prune_old_backups