使用pg_restore从较新版本的PostgreSQL还原 [英] Use pg_restore to restore from a newer version of PostgreSQL
问题描述
在生产机器上,我运行:
pg_dump -f nvdls.db -F p -U nvdladmin nvdlstats
开开发机器,我运行:
pg_restore -d nvdlstats -U nvdladmin nvdls.db
我收到这个错误:
pg_restore:文件夹中的[archiver]不支持的版本(1.12)
无论是否选择自定义,tar或plain_text格式。
我发现一个在线讨论,这表明我应该在开发机器上使用较新版本的 pg_restore
。我尝试通过简单地将9.0二进制文件复制到开发机器,但是由于链接问题而导致失败(不出人意料地)。
我认为使用plain_text转储是它将是原始的,可移植的SQL。显然不是。
如何将9.0数据库存入我的8.4安装?
pg_restore仅仅用于恢复以自定义格式采集的转储。
如果您执行纯文本转储您必须使用psql来运行生成的SQL脚本:
psql -f nvdls.db dbname用户名
I have a (production) DB server running PostgreSQL v9.0 and a development machine running PostgreSQL v8.4. I would like to take a dump of the production DB and use it on the development machine. I cannot upgrade the postgres on the dev machine.
On the production machine, I run:
pg_dump -f nvdls.db -F p -U nvdladmin nvdlstats
On the development machine, I run:
pg_restore -d nvdlstats -U nvdladmin nvdls.db
And I got this error:
pg_restore: [archiver] unsupported version (1.12) in file header
This occurs regardless of whether I choose the custom, tar, or plain_text format when dumping.
I found one discussion online which suggests that I should use a newer version of pg_restore
on the dev machine. I tried this by simply copying the 9.0 binary to the dev machine, but this fails (not unexpectedly) due to linking problems.
I thought that the point of using a plain_text dump was that it would be raw, portable SQL. Apparently not.
How can I get the 9.0 DB into my 8.4 install?
pg_restore is only for restoring dumps taken in the "custom" format.
If you do a "plain text" dump you have to use psql to run the generated SQL script:
psql -f nvdls.db dbname username
这篇关于使用pg_restore从较新版本的PostgreSQL还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!