When loading a database dump created with pg_dump
into your database, you might run into an error like
pg_restore: error: unsupported version (1.15) in file header
This is because your local pg_restore
version is too old to match the dump format.
For example, the official Ubuntu 20.04 sources include only PostgreSQL 12, so your pg_restore
version will also be v12. Ubuntu 22.04 includes version 14 in its sources.
Both seem to be incompatible with dumps created by PG 16's pg_dump
, for example.
If you cannot upgrade to the latest PostgreSQL version, you can find a workaround below.
Add the official PostgreSQL APT sources Show archive.org snapshot as described in the official PostgreSQL documentation.
Then, run sudo apt update
and sudo apt full-upgrade
. This might already install the latest version.
After adding the official sources, you can install any specific version. For example,
sudo apt install postgresql-client-16
installs only the PG 16 client, including version 16 of pg_restore
sudo apt install postgresql-16
installs PG 16 server and client./etc/postgresql/*/main/postgresql.conf
for that.pg_restore
, you can use newer versions to load dumps created by older versions of pg_dump
.apt update
prints a warning like Skipping acquire of configured file 'main/binary-i386/Packages' as repository
, edit /etc/apt/sources.list.d/pgdg.list
(as root!) and add your architecture. Most likely, you need to put [arch=amd64]
after deb
so that it reads deb [arch=amd64] https://...
.host
option The latest PostgresQL client will only be used when you connect to your database using the host
option.
When using pg_restore
, pass a --host=localhost
parameter.
When using
geordi dump
Show archive.org snapshot
, you need to modify your config/database.yml
to include a host
option:
# database.yml
development:
host: localhost