Created
November 25, 2016 12:39
-
-
Save kalys/a826d8d719d6a599d48ce4c80bb68ae1 to your computer and use it in GitHub Desktop.
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 | |
# you should install aws-cli | |
# create iam account for s3 bucket | |
# run ```aws configure``` and set id and secret | |
# then configure s3 bucket policy | |
# | |
# { | |
# "Version": "2012-10-17", | |
# "Statement": [ | |
# { | |
# "Sid": "", | |
# "Effect": "Allow", | |
# "Principal": { | |
# "AWS": "__iam-id__" | |
# }, | |
# "Action": "s3:*", | |
# "Resource": "arn:aws:s3:::__bucket_name__/*" | |
# } | |
# ] | |
# } | |
TODAY=`date --iso-8601` | |
DUMPFILE=/tmp/backups/backup-$TODAY.sql.gz | |
mkdir -p /tmp/backups | |
sudo -u postgres pg_dump -d database_name | gzip > $DUMPFILE | |
/path/to/bin/aws s3 cp $DUMPFILE s3://s3_bucket/ | |
rm $DUMPFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment