pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ROCHER Julien <julien.rocher@emeria.eu>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: TR: Issue: --exclude-schema flag not working with pgrestore
Date: Wed, 11 Jan 2023 09:07:08 +0000
Message-ID: <PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <PR0P264MB04922339584F1611C4775B8CEDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM>
References: <PR0P264MB04922339584F1611C4775B8CEDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM>

Hi,

I don’t expect the --exclude-schema flag (-N) to restore chosen schema with pgrestore<https://docs.postgresql.fr/11/app-pgrestore.html; 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<mailto:julien.rocher@emeria.eu>



view thread (3+ messages)  latest in thread

Message-ID: <PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM>
Permalink:  ../PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: julien.rocher@emeria.eu
  Subject: Re: TR: Issue: --exclude-schema flag not working with pgrestore
  In-Reply-To: <PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM>
  References: <PR0P264MB04922339584F1611C4775B8CEDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM> <PR0P264MB049277C2C09E857806770496EDFC9@PR0P264MB0492.FRAP264.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox