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. 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

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.


Solution 1:

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.

The security patch can be found here 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).

Solution 2:

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.)

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).

I had to upgrade Postgres.app from 2.1.0 to 2.1.3 and it solved the problem.

Solution 3:

First time I've had this issue, here's how I restored the Heroku Database to my Local:

$ rails db:drop
$ heroku pg:pull DATABASE_URL <insert local DB name> --app <app-name>

Solution 4:

Since yesterday (03/01/2018) we also had problems restoring a backup from Heroku running on PostgreSQL 9.5:

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.

Solution 5:

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/

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