Categories
Programming

Transferring Data in Postgres

“We believe that databases need to excel at more than simple selects to be useful for complex tasks, and our positive experiences with PostgreSQL has done nothing but reinforce that philosophy.”

– David McNett

Migrating data hardly ever comes without headaches and the odd “oh shit” moments, but after getting the hang of it, you realize a great level of control.

Postgres comes with two utilities that make it simple to extract a database and restore it to another destination, with flexible options to select which parts of the data you want restored:

  • pg_dump is a utility for consistent back-ups of a PostgreSQL database, even if the database is being used concurrently.
  • pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats.