Skip to content

Instantly share code, notes, and snippets.

@petedoyle
Created April 20, 2012 22:42
Show Gist options
  • Save petedoyle/2432419 to your computer and use it in GitHub Desktop.
Save petedoyle/2432419 to your computer and use it in GitHub Desktop.
Backup postgres, upload to s3 using s3cmd
#!/bin/bash
if [ -z "$1" ]
then
FILENAME=pg_dumpall_$(date +"%Y%m%d-%H:%M:%S").sql.gz
else
FILENAME=$1
fi
FQ_FILENAME=/var/lib/pgsql/backups/$FILENAME
su -c "pg_dumpall | gzip -c > $FQ_FILENAME" postgres
s3cmd --config=/root/config/servers/db1/scripts/s3cfg --acl-private --encrypt put $FQ_FILENAME s3://my.bucket.com/postgres/$FILENAME.gpg
rm -f $FQ_FILENAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment