Hi,
I don’t expect the --exclude-schema flag (-N) to restore chosen schema with pgrestore tool, but it actually tries to create the schema then its table.
I deliberately keep the same db name in the below example because this is actually what I’m trying to do (restore a dump from a similar db but excluding some already existing schemas on it), but I guess you don’t need to deal with this detail.
Did I misunderstand this command ?
➜ ~ psql -U julien -W -p 5432 -d postgres -c "create schema schemaA; create schema schemaB;"
Password:
CREATE SCHEMA
CREATE SCHEMA
➜ ~ psql -U julien -W -p 5432 -d postgres -c "create table schemaA.tableA(f int); create table schemaB.tableB(f int);"
Password:
CREATE TABLE
CREATE TABLE
➜ ~ pg_dump -p 5432 -W -d postgres --format=c > dump.sql
Password:
➜ ~ pg_restore -p 5432 -W -d postgres --verbose -N schemaB dump.sql
pg_restore: connecting to database for restore
Password:
pg_restore: creating SCHEMA "schemaa"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 6; 2615 16389 SCHEMA schemaa julien
pg_restore: error: could not execute query: ERROR: schema "schemaa" already exists
Command was: CREATE SCHEMA schemaa;
pg_restore: creating SCHEMA "schemab"
pg_restore: from TOC entry 7; 2615 16390 SCHEMA schemab julien
pg_restore: error: could not execute query: ERROR: schema "schemab" already exists
Command was: CREATE SCHEMA schemab;
pg_restore: creating TABLE "schemaa.tablea"
pg_restore: from TOC entry 216; 1259 16391 TABLE tablea julien
pg_restore: error: could not execute query: ERROR: relation "tablea" already exists
Command was: CREATE TABLE schemaa.tablea (
f integer
);
pg_restore: creating TABLE "schemab.tableb"
pg_restore: from TOC entry 217; 1259 16394 TABLE tableb julien
pg_restore: error: could not execute query: ERROR: relation "tableb" already exists
Command was: CREATE TABLE schemab.tableb (
f integer
);
pg_restore: processing data for table "schemaa.tablea"
pg_restore: processing data for table "schemab.tableb"
pg_restore: warning: errors ignored on restore: 4
Julien ROCHER |
Développeur Team Data - Migration |
|
Emeria Technologies |
76-78 Avenue des Champs Elysées – 75008 Paris |
06 17 17 60 64 |
julien.rocher@emeria.eu |