Easy way to view postgresql dump files?

DatabasePostgresql 9.1Pg Dump

Database Problem Overview


I have a ton of postgresql dump files I need to peruse through for data. Do I have to install Postgresql and "recover" each one of them into new databases one by one? Or I'm hoping there's a postgresql client that can simply open them up and I can peek at the data, maybe even run a simple SQL query?

The dump files are all from a Postgresql v9.1.9 server.

Or maybe there's a tool that can easily make a database "connection" to the dump files?

UPDATE: These are not text files. They are binary. They come from Heroku's backup mechanism, this is what Heroku says about how they create their backups:

> PG Backups uses the native pg_dump PostgreSQL tool to create its > backup files, making it trivial to export to other PostgreSQL > installations.

Database Solutions


Solution 1 - Database

This was what I was looking for:

pg_restore db.bin > db.sql

Thanks @andrewtweber

Solution 2 - Database

Try opening the files with text editor - the default dump format is plain text.

If the dump is not plain text - try using pg_restore -l your_db_dump.file command. It will list all objects in the database dump (like tables, indexes ...).

Another possible way (may not work, haven't tried it) is to grep through the output of pg_restore your_db_dump.file command. If I understood correctly the manual - the output of pg_restore is just a sequence of SQL queries, that will rebuild the db.

Solution 3 - Database

In newer versions you need to specify the -f flag with a filename or '-' for stdout

pg_restore dump_file.bin -f -

Solution 4 - Database

I had this same problem and I ended up doing this:

  1. Install Postgresql and PGAdmin3.
  2. Open PGAdmin3 and create a database.
  3. Right click the db and click restore.
  4. Ignore file type.
  5. Select the database dump file from Heroku.
  6. Click Restore.

Solution 5 - Database

Dump files are usually text file, if Not compressed, and you can open them with a text editor. Inside you will find all the queries that allow the reconstruction of the database ...

Solution 6 - Database

If you use pgAdmin on Windows, can just backup the file as plain text, there is one option when you do backup instead of pg_dump in command line prompt.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionat.View Question on Stackoverflow
Solution 1 - DatabasejcuenodView Answer on Stackoverflow
Solution 2 - DatabaseIhor RomanchenkoView Answer on Stackoverflow
Solution 3 - DatabaseAlexDevView Answer on Stackoverflow
Solution 4 - DatabaseAaron GrayView Answer on Stackoverflow
Solution 5 - DatabasealerootView Answer on Stackoverflow
Solution 6 - DatabaseTonyTonyView Answer on Stackoverflow