Skip to content

Instantly share code, notes, and snippets.

@buddylindsey
Created April 8, 2014 19:29
Show Gist options
  • Select an option

  • Save buddylindsey/10176591 to your computer and use it in GitHub Desktop.

Select an option

Save buddylindsey/10176591 to your computer and use it in GitHub Desktop.
Automated Postgres Backup
import sys
import boto
from boto.s3.connection import S3Connection
from boto.s3.key import Key
file_name = sys.argv[1]
AWSAccessKeyId = ''
AWSSecretKey = ''
conn = S3Connection(AWSAccessKeyId, AWSSecretKey)
bucket = conn.get_bucket('bucket_name')
k = Key(bucket)
k.key = file_name
k.set_contents_from_filename(file_name)
#!/bin/bash
FILE_LOC="/var/backups/postgresql"
FILE_NAME="db_name-`date +"%d-%m-%Y"`.sql"
pg_dump db_name > "$FILE_LOC/$FILE_NAME"
python $FILE_LOC/awsup.py "$FILE_LOC/$FILE_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment