Restoring old Postgres dumps with pg_restore v11 and higher

There is an issue with when restoring a PostgreSQL dump created with pg_dump < v11 with pg_restore > v10:

pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public"
already exists
    Command was: CREATE SCHEMA public;

Convert

If you want to restore this dump you should convert the dump to the text format first and comment out the CREATE SCHEMA public; statement. For further information see linked content.

Use different pg_restore

After adding the PostgreSQL APT respository Show archive.org snapshot you can install additional client versions on your local machine with apt install postgresql-client-$VERSION. You'll find them here: /usr/lib/postgresql/$VERSION/bin/pg_restore.


Also see our card on importing Postgres dumps created with newer versions.

Claus-Theodor Riegg Over 4 years ago