Backup schema without data

Started by Atul Kumarabout 3 years ago4 messagesgeneral
Jump to latest
#1Atul Kumar
akumar14871@gmail.com

Hi,

Please help me in telling that how I can take the backup of one single
schema without its data using pg_dump utility ?

So far, I could not find anything suitable for doing so.

Regards,
Atul

#2Michael Loftis
mloftis@wgops.com
In reply to: Atul Kumar (#1)
Re: Backup schema without data

From the man page….

-s
--schema-only

Dump only the object definitions (schema), not data.

…..”

On Thu, Apr 6, 2023 at 18:40 Atul Kumar <akumar14871@gmail.com> wrote:

Hi,

Please help me in telling that how I can take the backup of one single
schema without its data using pg_dump utility ?

So far, I could not find anything suitable for doing so.

Regards,
Atul

--

"Genius might be described as a supreme capacity for getting its possessors
into trouble of all kinds."
-- Samuel Butler

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Atul Kumar (#1)
Re: Backup schema without data

Atul Kumar <akumar14871@gmail.com> writes:

Please help me in telling that how I can take the backup of one single
schema without its data using pg_dump utility ?

Doesn't "pg_dump -s -n <schema> ..." do what you want?

regards, tom lane

#4Brent Wood
pcreso@yahoo.com
In reply to: Atul Kumar (#1)
Re: Backup schema without data

Looking at the result of:

pg_dump --help
Usage:
  pg_dump [OPTION]... [DBNAME]
...  -n, --schema=PATTERN         dump the specified schema(s) only...
 -s, --schema-only            dump only the schema, no data... 

So: pg_dump -s -n <schema> <db>

It works for me...

Cheers
Brent Wood

On Friday, April 7, 2023 at 12:40:58 PM GMT+12, Atul Kumar <akumar14871@gmail.com> wrote:

Hi,
Please help me in telling that how I can take the backup of one single schema without its data using pg_dump utility ?

So far, I could not find anything suitable for doing so.
Regards,Atul