我有大量的Postgresql转储文件,我需要仔细阅读这些文件以获取数据。我必须安装Postgresql并将它们中的每一个恢复到新数据库中吗?还是我希望有一个postgresql客户端可以简单地打开它们,我可以查看数据,甚至可以运行简单的SQL查询?
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?
转储文件是全部来自Postgresql v9.1.9服务器。
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 :这些是非文本文件。它们是二进制。它们来自Heroku的备份机制,这是关于Heroku如何创建备份的说法:
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备份使用本机pg_dump PostgreSQL工具创建其备份文件,从而导出到其他PostgreSQL 安装。
PG Backups uses the native pg_dump PostgreSQL tool to create its backup files, making it trivial to export to other PostgreSQL installations.
推荐答案
尝试使用文本编辑器打开文件-默认转储格式为纯文本。
Try opening the files with text editor - the default dump format is plain text.
如果转储不是纯文本,请尝试使用 pg_restore -l your_db_dump.file 命令。它将列出数据库转储中的所有对象(如表,索引...)。
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 ...).
另一种可能的方法(可能不起作用,没有尝试过)是 grep 通过 pg_restore your_db_dump.file 命令的输出。如果我正确理解了手册- pg_restore 的输出只是一系列SQL查询,则将重建数据库。
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.
更多推荐
查看postgresql转储文件的简单方法?
发布评论