Skip to content

Instantly share code, notes, and snippets.

@cime
Forked from jgillman/restore.sh
Last active July 13, 2018 17:14
Show Gist options
  • Save cime/a9e73fdd2a291413a9c07d3d6cb1fb17 to your computer and use it in GitHub Desktop.
Save cime/a9e73fdd2a291413a9c07d3d6cb1fb17 to your computer and use it in GitHub Desktop.
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_NAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
sleep 5
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_NAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment