Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 464
sorin Avatar asked Jan 29 '14 11:01

sorin


People also ask

What is Pgdmp file?

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.

What is dump file in PostgreSQL?

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.

How does pg_ dump work?

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 .

Where does pg_dump save file?

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.


1 Answers

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  
like image 123
Craig Ringer Avatar answered Sep 21 '22 11:09

Craig Ringer