Instantly share code, notes, and snippets.

Embed
What would you like to do?
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