Skip to content

Instantly share code, notes, and snippets.

@kalys
Created Nov 25, 2016
Embed
What would you like to do?
#!/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