diff --git a/postgres-backup-s3/backup.sh b/postgres-backup-s3/backup.sh index e37273c..47a79a6 100644 --- a/postgres-backup-s3/backup.sh +++ b/postgres-backup-s3/backup.sh @@ -66,8 +66,10 @@ echo "Creating dump of ${POSTGRES_DATABASE} database from ${POSTGRES_HOST}..." pg_dump $POSTGRES_HOST_OPTS $POSTGRES_DATABASE | gzip > dump.sql.gz -echo "Uploading dump to $S3_BUCKET" +FILENAME=${DB_ENV_PREFIX}_${POSTGRES_DATABASE}_$(date +"%Y-%m-%dT%H_%M_%SZ").sql.gz -cat dump.sql.gz | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PREFIX/${DB_ENV_PREFIX}_${POSTGRES_DATABASE}_$(date +"%Y-%m-%dT%H_%M_%SZ").sql.gz || exit 2 +echo "Uploading dump named $FILENAME to $S3_BUCKET" + +cat dump.sql.gz | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PREFIX/$FILENAME || exit 2 echo "SQL backup uploaded successfully"