TR: Issue: --exclude-schema flag not working with pgrestore - Mailing list pgsql-bugs

From ROCHER Julien
Subject TR: Issue: --exclude-schema flag not working with pgrestore
Date
Msg-id PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: TR: Issue: --exclude-schema flag not working with pgrestore  (Julien Rouhaud <rjuju123@gmail.com>)
List pgsql-bugs

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

 

pgsql-bugs by date:

Previous
From: Frank Reppin
Date:
Subject: Re: BUG #17733: ERROR: could not load library "/Users/frank/postgres/postgresql-13.9/lib/postgresql/llvmjit.so": dl
Next
From: Julien Rouhaud
Date:
Subject: Re: TR: Issue: --exclude-schema flag not working with pgrestore