Skip to content

Instantly share code, notes, and snippets.

@wotori
Created September 7, 2022 10:19
Show Gist options
  • Save wotori/72e01e66feb3e061be4bb9318f28181f to your computer and use it in GitHub Desktop.
Save wotori/72e01e66feb3e061be4bb9318f28181f to your computer and use it in GitHub Desktop.
postgres

dump remote

pg_dump --dbname=postgresql://postgres:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME -f ~/backup.sql

dump into db

pg_dump --dbname=postgresql://postgres:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME | psql -U postgres DB_NAME

docker example

docker exec local_pg_container bash -c "pg_dump --dbname=postgresql://postgres:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME | psql -U postgres DB_NAME"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment