Skip to content

Instantly share code, notes, and snippets.

@vietch2612
Forked from jgillman/restore.sh
Last active July 14, 2021 06:44
Show Gist options
  • Save vietch2612/d019047e0529700ab790a0936c00dab9 to your computer and use it in GitHub Desktop.
Save vietch2612/d019047e0529700ab790a0936c00dab9 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_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
pg_restore --clean --no-owner -U vietcao -d sc-app-ror_development -1 /path/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment