Migrating between PostgreSQL Databases


Here’s how to move from one PostgreSQL DB to another PostgreSQL DB.

Some uses for this could include:

  • Creating backups
  • Cloning a production DB to a development DB for debugging

Export

$ pg_dump [database_name] > [import_file]

Example

$ pg_dump my_postgres_db > dump.sql

Import

$ psql [database_name] < [import_file]

Example

$ psql my_postgres_db < dump.sql
comments powered by Disqus