Skip to content

Instantly share code, notes, and snippets.

@dwilkie
Last active May 8, 2022 08:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwilkie/df4e1d3fa47d62cfe2e627f021678824 to your computer and use it in GitHub Desktop.
Save dwilkie/df4e1d3fa47d62cfe2e627f021678824 to your computer and use it in GitHub Desktop.
Elastic Beanstalk pg_dump
# On Elastic Beanstalk machine
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-libs-11.4-1PGDG.rhel6.x86_64.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-11.4-1PGDG.rhel6.x86_64.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-server-11.4-1PGDG.rhel6.x86_64.rpm
pg_dump --version
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
source $EB_SUPPORT_DIR/envvars
source $EB_SCRIPT_DIR/use-app-ruby.sh
pg_dump -Fc $DATABASE_URL > latest.dump
aws s3 cp latest.dump s3://backups.somleng.org/db/twilreapi_latest.dump
# On local machine
pg_restore --verbose --clean --no-acl --no-owner -d "postgres://localhost:5432/twilreapi_development" ~/Downloads/twilreapi_latest.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment