How do I convert a binary pgdump (compressed) to a plain SQL file?

sorin picture sorin · Jan 29, 2014 · Viewed 29.9k times · Source

I do want to search for some data inside a database dump but these dumps are using the binary-compressed format (PGDMP header).

How can I convert these to SQL without restoring them?

Answer

Craig Ringer picture Craig Ringer · Jan 29, 2014

pg_restore, when run without a database name, outputs a text dump to stdout; you can send that elsewhere with -f or with I/O redirection.

pg_restore -f mydatabase.sql mydatabase.dump