Re: Restoring only a subset of schemas

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sylvain Cuaz <sylvain(at)ilm-informatique(dot)fr>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Restoring only a subset of schemas
Date: 2025-03-17 15:29:36
Message-ID: 4009720.1742225376@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sylvain Cuaz <sylvain(at)ilm-informatique(dot)fr> writes:
>     Now if I want to restore from a full dump of this DB, but with only one "cXXX" and the "Common"
> schema :
> - if I pass --create --schema=Common, then the CREATE SCHEMA is missing, i.e. it only emits data
> inside "Common" and the restore fails.
> - if I could pass --create --exclude-schema='c*' (fictional notation as patterns are only recognized
> by pg_dump), then all schemas would be created, with no data inside except for "Common". Creating
> all schemas is a waste of time, but more importantly would make restoring other schemas more
> difficult (e.g. rows should be inserted before creating foreign keys).

In general, the solution for edge-case restore selection needs is to
make a list of the dump's contents with "pg_restore -l", edit out what
you don't want using any method you like, then use the edited list with
"pg_restore -L".

While I'd be in favor of improving pg_restore to accept wild-card
patterns, I'm very hesitant to start inventing new kinds of selection
switches for it. The interactions between such switches would be a
mess.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2025-03-17 18:33:52 Re: Creating a new database on a different file system
Previous Message Adrian Klaver 2025-03-17 15:21:11 Re: Restoring only a subset of schemas