Skip to content

Instantly share code, notes, and snippets.

@pindlebot
Last active October 19, 2018 16:59
Show Gist options
  • Select an option

  • Save pindlebot/10fb3b54e73d92f3b2c43d6fdfa8f808 to your computer and use it in GitHub Desktop.

Select an option

Save pindlebot/10fb3b54e73d92f3b2c43d6fdfa8f808 to your computer and use it in GitHub Desktop.
#!/bin/bash
DATE=`date +%m-%d-%Y`
HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/public-hostname)
AWS_BUCKET=postgres-data
AWS_REGION=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}')
export PGUSER=postgres
pg_dumpall | aws --region $AWS_REGION s3 cp - "s3://$AWS_BUCKET/$HOSTNAME/$DATE.bak"
echo "Backup saved on $(date)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment