pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Holger Jakobs <holger@jakobs.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: pg_dump / pgrestore question - cannot restore a single schema
Date: Tue, 24 Mar 2020 01:55:32 +0100
Message-ID: <1226ea80-e760-54ff-47e3-c2a0c90cf1e0@jakobs.com> (raw)
In-Reply-To: <CAKFQuwYx6OWRA2WF3RkHgB13RZTSrRU44LiGYcwb7+O-LWuUTQ@mail.gmail.com>
References: <5144169d-9913-2261-2ec0-3045679a8477@quadratum-braccas.com>
	<CAKFQuwYx6OWRA2WF3RkHgB13RZTSrRU44LiGYcwb7+O-LWuUTQ@mail.gmail.com>

You could also extract the commands for creating the schema contained in 
the dump using the following commands:

schemaname=whatever_your_schemaname_is
pg_restore -l /tmp/dump | grep "SCHEMA - $schemaname" > 
/tmp/objects_to_re-create
pg_restore -L /tmp/objects_to_re-create -f - /tmp/my_custom_dump | psql

and then

pg_restore -n "$schemaname" /tmp//tmp/my_custom_dump | psql

in order to re-create the contents of the schema.

Regards,

Holger

Am 24.03.20 um 01:40 schrieb David G. Johnston:
> On Mon, Mar 23, 2020 at 4:47 PM S.Bob <sbob@quadratum-braccas.com 
> <mailto:sbob@quadratum-braccas.com>> wrote:
>
>     However if I try to restore only one of the schemas it does not
>     work, seems like it does not create the schema first:
>
> Since you have to know the schema name anyway in order to restore that 
> schema only just go ahead an create the schema before performing the 
> restore.  It seems that since a schema is not "in itself" it doesn't 
> get restored.  Doesn't seem like a problem.
>
> David J.
>
-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012

view thread (3+ messages)

Message-ID: <1226ea80-e760-54ff-47e3-c2a0c90cf1e0@jakobs.com>
Permalink:  ../1226ea80-e760-54ff-47e3-c2a0c90cf1e0@jakobs.com/
Also on:    postgresql.org/message-id/1226ea80-e760-54ff-47e3-c2a0c90cf1e0@jakobs.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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: holger@jakobs.com, pgsql-admin@lists.postgresql.org
  Subject: Re: pg_dump / pgrestore question - cannot restore a single schema
  In-Reply-To: <1226ea80-e760-54ff-47e3-c2a0c90cf1e0@jakobs.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