Browse Source

encrypt after pg_dump (#156)

pull/157/head
ajctrl 2 years ago
committed by GitHub
parent
commit
ec69104d8f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      postgres-backup-s3/backup.sh

8
postgres-backup-s3/backup.sh

@ -94,7 +94,10 @@ else
SRC_FILE=dump.sql.gz SRC_FILE=dump.sql.gz
DEST_FILE=${DB}_$(date +"%Y-%m-%dT%H:%M:%SZ").sql.gz DEST_FILE=${DB}_$(date +"%Y-%m-%dT%H:%M:%SZ").sql.gz
echo "Creating dump of ${DB} database from ${POSTGRES_HOST}..."
pg_dump $POSTGRES_HOST_OPTS $DB | gzip > $SRC_FILE
if [ "${ENCRYPTION_PASSWORD}" != "**None**" ]; then if [ "${ENCRYPTION_PASSWORD}" != "**None**" ]; then
echo "Encrypting ${SRC_FILE}" echo "Encrypting ${SRC_FILE}"
openssl enc -aes-256-cbc -in $SRC_FILE -out ${SRC_FILE}.enc -k $ENCRYPTION_PASSWORD openssl enc -aes-256-cbc -in $SRC_FILE -out ${SRC_FILE}.enc -k $ENCRYPTION_PASSWORD
@ -106,9 +109,6 @@ else
DEST_FILE="${DEST_FILE}.enc" DEST_FILE="${DEST_FILE}.enc"
fi fi
echo "Creating dump of ${DB} database from ${POSTGRES_HOST}..."
pg_dump $POSTGRES_HOST_OPTS $DB | gzip > $SRC_FILE
echo "Uploading dump to $S3_BUCKET" echo "Uploading dump to $S3_BUCKET"
cat $SRC_FILE | aws $AWS_ARGS s3 cp - "s3://${S3_BUCKET}${S3_PREFIX}${DEST_FILE}" || exit 2 cat $SRC_FILE | aws $AWS_ARGS s3 cp - "s3://${S3_BUCKET}${S3_PREFIX}${DEST_FILE}" || exit 2

Loading…
Cancel
Save