Re: Dump a database excluding one table DATA?

From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: dmitry(at)koterov(dot)ru
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dump a database excluding one table DATA?
Date: 2011-08-19 21:20:38
Message-ID: m2sjoxw121.fsf@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dmitry Koterov <dmitry(at)koterov(dot)ru> writes:
> Is there any way (or hack) to dump the whole database, but to exclude the
> DATA from a table within this dump? (DDL of the table should not be
> excluded: after restoring the data the excluded table should look "empty".)

The pg_staging tool allows you to do that quite easily, once you've done
the initial setup (involved, but nothing fancy).

https://github.com/dimitri/pg_staging
http://tapoueh.org/pgsql/pgstaging.html

If you want to exclude the table from the dumps though (data loss issues
are looking at you), what I would advice is create a dedicated schema
and skipping the whole schema at dump time, using the following option:

--exclude-schema=schema
Do not dump any schemas matching the schema
pattern. The pattern is interpreted according to the
same rules as for -n. -N can be given more than once
to exclude schemas matching any of several patterns.

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message TJ O'Donnell 2011-08-19 21:22:53 array_agg problem
Previous Message Edoardo Panfili 2011-08-19 20:37:49 Re: A questions on planner choices