Created
January 6, 2019 07:03
-
-
Save 0xDing/0b5c7deccf0c527f3a517a20b596746a to your computer and use it in GitHub Desktop.
backup postgresql database to aws s3
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/sh | |
CURRENT=`date +%s` | |
HOST="xxx.rds.amazonaws.com" | |
S3BUCKET = 'XXX' | |
DUMP="${DB}.${CURRENT}-full.tar" | |
echo "starting dump datbase..." | |
pg_dump -h ${HOST} -p 5432 -U ${USER} -w -d ${DB} -O -v -F tar -f ${DUMP} | |
lzop -Uv ${DUMP} | |
# apt-get install lzop | |
md5sum --tag ${DUMP}.lzo > ${DUMP}.lzo.md5 | |
aws s3 cp ${DUMP}.lzo s3://${S3BUCKET}/ | |
aws s3 cp ${DUMP}.lzo.md5 s3://${S3BUCKET}/ | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment