简体   繁体   English

运行 pg_restore 时在文件头中获取“[archiver] 不受支持的版本(1.13)”

[英]Getting "[archiver] unsupported version (1.13) in file header" when running pg_restore

I just upgraded to postgres 10.2 on mac os which matches 10.2 on heroku.我刚刚在 mac os 上升级到 postgres 10.2,它与 heroku 上的 10.2 匹配。 I'm trying to download a copy of the database and restore it locally.我正在尝试下载数据库的副本并在本地恢复它。 Before the upgrade the restore would work fine.在升级之前,恢复工作正常。

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.这是一个 rails 应用程序,我升级了 pg gems。 I can run rake db:create and db:migrate just fine.我可以运行rake db:createdb:migrate就好了。

You need to upgrade your local postgres to get the last security patch from the 2018-03-01, like Heroku did the 1st march.您需要升级本地 postgres 以获得 2018-03-01 的最后一个安全补丁,就像Heroku在 3 月 1 日所做的那样。 You need one of the last releases 10.3 , 9.6.8 , 9.5.12 , 9.4.17 , and 9.3.22 .您需要最新版本10.39.6.89.5.129.4.179.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 的转储(应用了补丁)。

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).如果您在 Mac 上使用 Postgres.app ( https://postgresapp.com/ ),请确保您运行的是v2.1.3 (在撰写本文时,这是最新版本)。 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).当您升级 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,它解决了这个问题。

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>

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 解决了这个问题。

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

The fix for me involved both updating my Postgres.app and updating my local homebrew PostgreSQL.我的修复包括更新我的 Postgres.app 和更新我的本地自制 PostgreSQL。

Update my Postgres.app via Canuk's answer:通过 Canuk 的回答更新我的 Postgres.app:

Open Postgres.app > Check for updates...打开 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

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.如果您使用第三方工具(例如 PgAdmin)来恢复提供的转储文件,即使安装的 Postgres 版本是最新的,恢复也可能不会成功。 This is due to third-party tools often bundling their own versions of the pg_restore binary, that may not be up to date.这是因为第三方工具经常捆绑他们自己版本的 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 https://help.heroku.com/YNH1ZJUS/why-am-i-getting-pg_restore-archiver-unsupported-version-1-13-in-file-header-error-with-pg_restore

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.首先,确保您拥有 diego 提到的 postgresql 存储库。 Then install the upgraded client.然后安装升级的客户端。

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 not have the updated client's you need.如果你的Ubuntu 17.04或17.10,注意PostgreSQL的兴致回购没有更新的客户端就是你需要的。 You will want to use the xenial Postgres repo instead.您将需要使用 xenial Postgres 存储库。

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

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.文件菜单 > 选项 > 二进制路径,然后将“PG bin 路径”更改为 postgresql/9.x/bin 而不是 ProgramFiles/pgadmin。 Restore worked fine afterwards.之后恢复工作正常。

You're using an old version of pg_restore binary that doesn't support restoring the provided dump file.您正在使用不支持恢复提供的转储文件的旧版本 pg_restore 二进制文件。 Please make sure that you use the latest Postgres version, which must be higher than the following release: https://www.postgresql.org/about/news/1834/ (10.3, 9.6.8, 9.5.12, 9.4.17, and 9.3.22).请确保您使用的是最新的 Postgres 版本,该版本必须高于以下版本: https ://www.postgresql.org/about/news/1834/ (10.3, 9.6.8, 9.5.12, 9.4.17 , 和 9.3.22)。

You can check the pg_restore version you're using by running pg_restore --version.您可以通过运行 pg_restore --version 检查您正在使用的 pg_restore 版本。

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.如果您使用第三方工具(例如 PgAdmin)来恢复提供的转储文件,即使安装的 Postgres 版本是最新的,恢复也可能不会成功。 This is due to third-party tools often bundling their own versions of the pg_restore binary, that may not be up to date.这是因为第三方工具经常捆绑他们自己版本的 pg_restore 二进制文件,这些版本可能不是最新的。

I was encountering the same error.我遇到了同样的错误。 I updated to postgresql 10.3 locally, and that fixed the problem for me.我在本地更新到 postgresql 10.3,这为我解决了问题。

For Windows:对于 Windows:

Open Command Prompt ( cmd ), then go to location C:\\Program Files\\PostgreSQL\\9.6\\bin and run these commands:打开命令提示符 ( cmd ),然后转到位置C:\\Program Files\\PostgreSQL\\9.6\\bin并运行以下命令:

pg_restore -U username -d dbname -1 filename.dump
pg_restore -U postgres -d app -1 G:\app09-07-2019.backup

Hope it will help you希望它会帮助你

I ran in the same issue 10 minutes ago, and found out about this thread from 2005: https://www.postgresql.org/message-id/1106163722.780395.266900%40z14g2000cwz.googlegroups.com我在 10 分钟前遇到了同样的问题,并从 2005 年发现了这个线程: https : //www.postgresql.org/message-id/1106163722.780395.266900%40z14g2000cwz.googlegroups.com

Basically the guy is saying the dump file is corrupt.基本上这家伙说转储文件已损坏。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pg_restore: [archiver] 文件头中不受支持的版本 (1.13) - pg_restore: [archiver] unsupported version (1.13) in file header pg_restore错误:pg_restore:文件头中的[archiver]不支持的版本(1.13) - pg_restore error: pg_restore: [archiver] unsupported version (1.13) in file header AWS Elatic Beanstalk和rails:pg_restore:文件头中的[archiver]不支持的版本(1.13) - AWS Elatic Beanstalk and rails: pg_restore: [archiver] unsupported version (1.13) in file header pg_restore: [archiver] 文件头中不支持的版本 (1.14) - pg_restore: [archiver] unsupported version (1.14) in file header 在 Heroku 上运行 pg:pull 时出现 pg_restore 错误 1 - Getting pg_restore error 1 when running pg:pull on Heroku pg_restore: [archiver] postgres 中的输入文件太短错误 - pg_restore: [archiver] input file is too short error in postgres pg_restore:[tar archiver] 在 tar 存档中找不到文件“toc.dat”的 header:- [PostgreSQL-11] pg admin 4 - pg_restore: [tar archiver] could not find header for file "toc.dat" in tar archive :- [PostgreSQL-11] pg admin 4 pg_restore: [目录归档程序] 无法打开输入文件。 尝试恢复数据库时出错 - pg_restore: [directory archiver] could not open input file. Error while trying to restore DB Postgres 教程:pg_restore:[archiver] 输入文件似乎不是有效的存档 - Postgres Tutorial: pg_restore: [archiver] input file does not appear to be a valid archive pg_restore:[存档]输入文件在使用Pgadmin 4的PostgreSQL中似乎不是有效的存档错误 - pg_restore: [archiver] input file does not appear to be a valid archive error in PostgreSQL using Pgadmin 4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM