Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sobstel
Created December 4, 2017 14:28
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 sobstel/4d4b9d3196f8122e563722bf1bc1e767 to your computer and use it in GitHub Desktop.
Save sobstel/4d4b9d3196f8122e563722bf1bc1e767 to your computer and use it in GitHub Desktop.
Heroku prod database export to Docker database container
#!/bin/bash
# stop on first error
set -e
command -v heroku >/dev/null 2>&1 || { echo >&2 "heroku command is required"; exit 1; }
command -v docker-compose >/dev/null 2>&1 || { echo >&2 "docker-compose command is required"; exit 1; }
DUMPFILE="/tmp/_FILENAME_.dump"
heroku pg:backups:download --output=$DUMPFILE --app=_APPNAME_
# This will usually generate some warnings, due to differences between your Heroku database
# and a local database, but they are generally safe to ignore.
docker-compose up -d db
docker-compose run db pg_restore --verbose --clean --no-acl --no-owner -h db -p 5432 -U postgres -d _DBNAME_ $DUMPFILE
docker-compose up -d api
docker-compose run api rails db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment