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?
pgdmp is a custom format file. Note that the custom format file is gzip-compressed and it is not required to compress it again. The PostgreSQL docs have more info about all the options for pg_dump and pg_dumpall.
Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to psql.
The pg_dump command extracts a PostgreSQL database into a script file or another archive file. This utility is for backing up databases. The utility makes consistent backups even if the database is being used concurrently. Readers, writers, and other users won't be blocked from using the database while using pg_dump .
sql , which uses the plain or SQL format, the pg_dump command does not store any file anywhere. It just sends the output to STDOUT , which is usually your screen, and it's done.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With