Created
June 7, 2015 23:22
-
-
Save leonsas/dc26fda3d80fae1be78c to your computer and use it in GitHub Desktop.
Heroku Backup to S3
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
import os | |
import arrow | |
from boto.s3.connection import S3Connection | |
S3_BACKUP_BUCKET = 'backup-bucket-name' | |
APP_NAME = 'myapp' | |
S3_REGION_HOSTNAME = 'e.g s3-us-west-1.amazonaws.com' | |
os.system('curl -o latest.dump `heroku pg:backups public-url --app %s`' % APP_NAME) | |
conn = S3Connection(host='s3-us-west-2.amazonaws.com') | |
bucket = conn.get_bucket(S3_BACKUP_BUCKET) | |
backup_name = arrow.now().format('X') | |
k = bucket.new_key(backup_name + '.dump') | |
k.set_contents_from_filename('latest.dump') | |
os.remove('latest.dump') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment