Skip to content

Instantly share code, notes, and snippets.

@hotsyk
Created December 3, 2010 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotsyk/727636 to your computer and use it in GitHub Desktop.
Save hotsyk/727636 to your computer and use it in GitHub Desktop.
Script to dump db and upload dump file to S3
#!/bin/bash
myfilename=$(date "+%Y-%m-%d_%H:%M")
pg_dump -U dbuser -w dbname | gzip > /var/www/dbbackups/dbname-$myfilename.dump.gz
/var/www/s3/s3-put -S -k <your-key> -s /var/www/dbbackups/secret.key -T /var/www/dbbackups/dbname-$myfilename.dump.gz /dbname-dbbackups/dbname/$myfilename-dbname.dump.gz
##you will need to get http://s3-bash.googlecode.com/files/s3-bash.0.02.tar.gz
##to ensure that secret file is 40 bytes, use
##echo -n your-secret-ket > secret.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment