Skip to content

Instantly share code, notes, and snippets.

@jfollmann
Last active December 20, 2022 16:58
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 jfollmann/da65cc2e9c36a4f0ec32fe1d456a9ca5 to your computer and use it in GitHub Desktop.
Save jfollmann/da65cc2e9c36a4f0ec32fe1d456a9ca5 to your computer and use it in GitHub Desktop.
How to create dump with docker to RDS postgres database

Create dump:

docker exec -i CONTAINER_NAME /bin/bash -c "PGPASSWORD=DATABASE_PASSWORD pg_dump --username DATABASE_USER -h RDS_HOST DATABASE_NAME" > ./dump.sql

Create local db to restore dump:

create database "db-restored"

Restore dump:

docker exec -i CONTAINER_NAME /bin/bash -c "PGPASSWORD=DATABASE_PASSWORD psql --username DATABASE_USER db-restored" < ./dump.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment