Created
December 4, 2017 14:28
-
-
Save sobstel/4d4b9d3196f8122e563722bf1bc1e767 to your computer and use it in GitHub Desktop.
Heroku prod database export to Docker database container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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