Skip to content

Instantly share code, notes, and snippets.

@mthri
Last active February 1, 2024 23:20
Show Gist options
  • Save mthri/a4b43c93bcbf967df426b713350e8b48 to your computer and use it in GitHub Desktop.
Save mthri/a4b43c93bcbf967df426b713350e8b48 to your computer and use it in GitHub Desktop.
export and import from PostgreSQL with pg_dump

Export

pg_dump -h HOST -p PORT -U DBUSER -W -d DBNAME > bak.sql

Import

pg_dump -h HOST -p PORT -U DBUSER -W -d NEWDBNAME < bak.sql
or
psql -h HOST -p PORT -U DBUSER -W -d NEWDBNAME -f bak.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment