3
C:\Program Files (x86)\pgAdmin III\1.22\pg_restore.exe --host localhost --port 5432 --username "postgres" --dbname "randd" --role "postgres" --no-password  --verbose "C:\Users\ranjeet\Desktop\RandDbackup19-3final.backup"

pg_restore: [archiver] unsupported version (1.13) in file header

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • 2
    Looks like the dump was taken with a higher version of PostgreSQL. – Laurenz Albe Mar 19 '19 at 06:48
  • I get this error if you use postgresql-9.5.15-1 and try to restore in postgresql-9.5.4-1, so good to know this is possible with the same 9.5 version – Cerveser Jan 28 '21 at 19:41

2 Answers2

6

No need to upgrade to the latest Postgres version.

We can backup and restore from any Postgres version to any as follows.

Create a backup in plain SQL format using pg_dump as follows in local/dev machine

pg_dump -U postgres -W -F p test > test.sql

Then use psql to restore dump on remote machine

psql -U postgres -W -d test -f test.sql

It works, on windows as well as Linux environments.

Please note if you see an error message while restoring on the remote machine like 'ERROR: unrecognized configuration parameter "default_table_access_method"'. You can simply ignore this message, as "default_table_access_method" option is introduced in Postgres 12 and while taking backedup added in sql file.

Pankaj Shinde
  • 3,361
  • 2
  • 35
  • 44
5

This error means that you are using an old and outdated version of pg_restore (and hence PostgreSQL) on the client side. The dump was created by a more recent release of PostgreSQL that the one installed, so your pg_restore does not know how to handle it.

Archive version 1.13 was introduced by commit 3d2aed664ee8271fd6c721ed0aa10168cda112ea in February 2018. It has been available since the point releases 10.3, 9.6.8, 9.5.12, 9.4.17 and 9.3.22.

You should upgrade your PostgreSQL installation, particularly because this release and this patch contain security relevant bug fixes.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • 2
    Looking at the file paths in the question, I assume it's because of the outdated pgAdmin 3 that includes those tools, rather than a local Postgres installation –  Mar 19 '19 at 07:48
  • 1
    Yes, that is probably the cause, and upgrading pgAdmin will probably help. – Laurenz Albe Mar 19 '19 at 07:59