postgresql 运行 pg_restore 时在文件头中获取“[archiver] 不受支持的版本(1.13)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49064209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting "[archiver] unsupported version (1.13) in file header" when running pg_restore
提问by Mark Swardstrom
I just upgraded to postgres 10.2 on mac os which matches 10.2 on heroku. I'm trying to download a copy of the database and restore it locally. Before the upgrade the restore would work fine.
我刚刚在 mac os 上升级到 postgres 10.2,它与 heroku 上的 10.2 匹配。我正在尝试下载数据库的副本并在本地恢复它。在升级之前,恢复工作正常。
I run
我跑
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d database_name backup.dump
but I am getting this error:
但我收到此错误:
pg_restore: [archiver] unsupported version (1.13) in file header
pg_restore: [archiver] 文件头中不受支持的版本 (1.13)
The database appears to be working OK. It's a rails app and I upgraded the pg gems. I can run rake db:create
and db:migrate
just fine.
数据库似乎工作正常。这是一个 rails 应用程序,我升级了 pg gems。我可以跑rake db:create
,db:migrate
很好。
回答by jumichot
You need to upgrade your local postgres to get the last security patch from the 2018-03-01, like Heroku
did the 1st march. You need one of the last releases 10.3
, 9.6.8
, 9.5.12
, 9.4.17
, and 9.3.22
.
您需要升级本地 postgres 以获取 2018-03-01 的最后一个安全补丁,就像Heroku
3 月 1日一样。你需要的最后版本之一10.3
,9.6.8
,9.5.12
,9.4.17
,和9.3.22
。
The security patch can be found here https://www.postgresql.org/about/news/1834/.
可以在此处找到安全补丁https://www.postgresql.org/about/news/1834/。
It seems the patch modified pg_dump, that's probably why we can't use pg_restore anymore without that patch for the dump of Heroku (with the patch applied).
似乎补丁修改了 pg_dump,这可能就是为什么我们不能在没有该补丁的情况下再使用 pg_restore 来进行 Heroku 的转储(应用了补丁)。
回答by Canuk
I ran into this same issue today, I don't know if something changed on Heroku's side, because locally I'm running 9.6 but my database on Heroku is 9.4, so it didn't seem to be about the version point difference (it was working until today.)
我今天遇到了同样的问题,我不知道 Heroku 方面是否有什么变化,因为我在本地运行的是 9.6,但我在 Heroku 上的数据库是 9.4,所以它似乎与版本点差异无关(它一直工作到今天。)
If you're using the Postgres.app (https://postgresapp.com/) on a Mac make sure you're running v2.1.3
(as of this writing that is the newest version). When you upgrade the Postgres.app you get the newest patch release of Postgres, (which is likely causing the mismatch you're currently experiencing - Heroku has upgraded for the latest security patch, and your local machine may not have it).
如果您在Mac 上使用 Postgres.app ( https://postgresapp.com/),请确保您正在运行v2.1.3
(在撰写本文时,这是最新版本)。当您升级 Postgres.app 时,您将获得 Postgres 的最新补丁版本,(这可能导致您当前遇到的不匹配 - Heroku 已升级为最新的安全补丁,而您的本地机器可能没有它)。
I had to upgrade Postgres.app from 2.1.0 to 2.1.3 and it solved the problem.
我不得不将 Postgres.app 从 2.1.0 升级到 2.1.3,它解决了这个问题。
回答by cbx
Since yesterday (03/01/2018) we also had problems restoring a backup from Heroku running on PostgreSQL 9.5:
从昨天 (03/01/2018) 开始,我们在从运行在 PostgreSQL 9.5 上的 Heroku 恢复备份时也遇到了问题:
pg_restore: [archiver] unsupported version (1.13) in file header
Upgrading our PostgreSQL version from 9.5.11 to 9.5.12 fixed the issue.
将我们的 PostgreSQL 版本从 9.5.11 升级到 9.5.12 解决了这个问题。
回答by Jim Padilla
First time I've had this issue, here's how I restored the Heroku Database to my Local:
我第一次遇到这个问题,以下是我将 Heroku 数据库恢复到本地的方法:
$ rails db:drop
$ heroku pg:pull DATABASE_URL <insert local DB name> --app <app-name>
回答by Diego Arag?o
For those who are trying to upgrade postgresql in Ubuntu without success (like Johan's commented above), try using the PostgreSQL apt repository, as stated in the official PostgreSQL download instructions: https://www.postgresql.org/download/linux/ubuntu/
对于那些尝试在 Ubuntu 中升级 postgresql 没有成功的人(如上面 Johan 的评论),请尝试使用 PostgreSQL apt 存储库,如官方 PostgreSQL 下载说明中所述:https: //www.postgresql.org/download/linux/ubuntu /
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
回答by Andrew
Had this problem on Windows using pgAdmin 3.
使用 pgAdmin 3 在 Windows 上有这个问题。
Upgrading from pgAdmin 3 to pgAdmin 4 solved the problem for me.
从 pgAdmin 3 升级到 pgAdmin 4 为我解决了这个问题。
If you are using a third-party tool, such as PgAdmin, to restore the provided dump file, the restore may not succeed even with the installed Postgres version being up to date. This is due to third-party tools often bundling their own versions of the pg_restore binary, that may not be up to date. https://help.heroku.com/YNH1ZJUS/why-am-i-getting-pg_restore-archiver-unsupported-version-1-13-in-file-header-error-with-pg_restore
如果您使用第三方工具(例如 PgAdmin)来恢复提供的转储文件,即使安装的 Postgres 版本是最新的,恢复也可能不会成功。这是因为第三方工具经常捆绑他们自己版本的 pg_restore 二进制文件,这些版本可能不是最新的。 https://help.heroku.com/YNH1ZJUS/why-am-i-getting-pg_restore-archiver-unsupported-version-1-13-in-file-header-error-with-pg_restore
回答by alxpck
The fix for me involved bothupdating my Postgres.app and updating my local homebrew PostgreSQL.
我的修复包括更新我的 Postgres.app 和更新我的本地自制 PostgreSQL。
Update my Postgres.app via Canuk's answer:
通过 Canuk 的回答更新我的 Postgres.app:
Update my local homebrew PostgreSQL via gerry3's comment on the accepted answer:
通过gerry3对已接受答案的评论更新我的本地自制PostgreSQL:
brew upgrade postgresql
brew postgresql-upgrade-database
brew upgrade postgresql
brew postgresql-upgrade-database
回答by Ivan
I don't recommend upgrading your DB to a new major version locally (do apply security patches) just to fix this as you want that to match whatever version you have in production.
我不建议将您的数据库升级到本地的新主要版本(应用安全补丁)只是为了解决这个问题,因为您希望它与您在生产中拥有的任何版本相匹配。
This fixed it on Ubuntu 16.04, restoring from a Heroku database.
这在 Ubuntu 16.04 上修复了它,从 Heroku 数据库恢复。
First, ensure you have the postgresql repo as diego mentioned. Then install the upgraded client.
首先,确保您拥有 diego 提到的 postgresql 存储库。然后安装升级的客户端。
sudo apt-get update && sudo apt-get install postgresql-client-10
sudo apt-get update && sudo apt-get install postgresql-client-10
If you are Ubuntu 17.04 or 17.10, note that the PostgreSQL's zesty repo does nothave the updated client's you need. You will want to use the xenial Postgres repo instead.
如果你的Ubuntu 17.04或17.10,注意PostgreSQL的兴致回购并不会有更新的客户端就是你需要的。您将需要使用 xenial Postgres 存储库。
回答by Rabi Cherian
Here is how I resolved the issue on Ubuntu(16.04 LTS) where pg_restore/pg_dump gave me an older version, from psql
这是我在 Ubuntu(16.04 LTS) 上解决问题的方法,其中 pg_restore/pg_dump 给了我一个旧版本,来自 psql
$ pg_restore --version
pg_restore (PostgreSQL) 9.4.8
$ psql --version
psql (PostgreSQL) 9.5.14
The issue is that I have multiple pg versions installed, and pg_restore was pointing to the earlier version
问题是我安装了多个 pg 版本,而 pg_restore 指向的是早期版本
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.4 main 5432 online postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log
9.5 main 5433 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
The fix is to create a ~/.postgresqlrc file pointing to the correct version
修复方法是创建一个指向正确版本的 ~/.postgresqlrc 文件
$ cat ~/.postgresqlrc
9.5 main *
Once this was done, pg_restore points to the correct version, and the command goes through
完成此操作后,pg_restore 指向正确的版本,命令将通过
Details given here: https://serverfault.com/questions/610777/wrong-version-of-pg-dump-on-ubuntu
此处给出的详细信息:https: //serverfault.com/questions/610777/wrong-version-of-pg-dump-on-ubuntu
回答by op op opself
I encountered this problem on pgadmin III and was able to fix it through switching the binaries location:
我在 pgadmin III 上遇到了这个问题,并且能够通过切换二进制文件位置来修复它:
File menu > Options > Binary Paths, then changed "PG bin path" to postgresql/9.x/bin instead of ProgramFiles/pgadmin. Restore worked fine afterwards.
文件菜单 > 选项 > 二进制路径,然后将“PG bin 路径”更改为 postgresql/9.x/bin 而不是 ProgramFiles/pgadmin。之后恢复工作正常。