Created
July 28, 2020 20:25
-
-
Save sandiprb/8bce374546965948495e42872f7893e1 to your computer and use it in GitHub Desktop.
Shell file to back up Postgres db & copy to s3 bucket
This file contains 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
DB_NAME=$1 | |
DB_USER=$2 | |
DB_PASS=$3 | |
BUCKET_NAME='bucket-name' | |
TIMESTAMP=$(date +%F_%T | tr ':' '-') | |
DB_FILE="$TIMESTAMP.sql" | |
PGPASSWORD=$DB_PASS pg_dump -Fc --no-acl -h localhost -U $DB_USER $DB_NAME > $DB_FILE | |
# copy to s3 | |
aws s3 cp $DB_FILE s3://$BUCKET_NAME | |
rm "$DB_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment