Skip site navigation (1) Skip section navigation (2)

Re: Truncate on pg_dump / pg_restore

From: Harold A(dot) Giménez Ch(dot) <harold(dot)gimenez(at)gmail(dot)com>
To: "Bryce Nesbitt" <bryce2(at)obviously(dot)com>
Cc: "chris smith" <dmagick(at)gmail(dot)com>, "sql pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Truncate on pg_dump / pg_restore
Date: 2008-10-25 15:36:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
You can, assuming you start off with a pg_dump in custom format (use -Fc).
You can use pg_restore's -l option to drop out the list contents of the
archive, and then comment out whatever you do not want restored:

pg_dump -Fc ....... > your_db.dump

pg_restore -l your_db.dump > your_db.list

# edit your_db.list and comment out whatever you don't need (or reorder if

# use your_db.list for the actual restore:

pg_restore -L your_db.list your_db.dump

Look at the examples on:

On Sat, Oct 25, 2008 at 11:23 AM, Bryce Nesbitt <bryce2(at)obviously(dot)com>wrote:

> chris smith wrote:
> On Sat, Oct 25, 2008 at 5:32 PM, Bryce Nesbitt <bryce2(at)obviously(dot)com> <bryce2(at)obviously(dot)com> wrote:
>  I've got
> tables with pretty disposable data... meaning I want to drop the data...
> but restore empty indexed tables at pg_restore time.
>  Do a schema-only dump.
> pg_dump --help says use '-s' or '--schema-only'.
>  Ooops, I was unclear.  I want most of the data!  There are just a few
> tables that I'd prefer be empty (truncated) in the restored database.  Most
> of the tables (and there are lots) are valuable.
> Could I  dump --schema-only, dump full, dump the toc, comment out the
> tables from the toc, restore the --schema-only, then restore the dump (minus
> the contents of the unwanted tables)?

In response to

pgsql-sql by date

Next:From: Bryce NesbittDate: 2008-10-25 21:42:32
Subject: SQL Statement Missing From Log
Previous:From: Bryce NesbittDate: 2008-10-25 15:23:46
Subject: Re: Truncate on pg_dump / pg_restore

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group