Created
July 6, 2020 17:08
-
-
Save jmrobles/9fd0b760d97bd3131b8bdbec629ff66f to your computer and use it in GitHub Desktop.
Backup Postgres DB Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export DUMP_FILE=/backup_`date +%Y%m%d_%H%M%S`.pgdump | |
PGPASSWORD=$POSTGRES_PASSWORD pg_dump -d $POSTGRES_DB -U $POSTGRES_USER -h $POSTGRES_HOST -f $DUMP_FILE | |
bzip2 $DUMP_FILE | |
mcrypt ${DUMP_FILE}.bz2 -k $DB_BACKUP_PASSWORD | |
aws s3 cp ${DUMP_FILE}.bz2.nc $S3_BACKUP_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment