Thread: pg_dump schma while excluding specific table

pg_dump schma while excluding specific table

From
Tony Capobianco
Date:
When I issue:

pg_dump newdb > /DUMPDIR/newdb.dmp -n dev -T corgi -w -v -F c 2> /DUMPDIR/newdb.log

I get a dump of the entire dev schema.  My goal is to dump the dev
schema minus the corgi table.  How can I adjust my script to perform
this function?

Thanks.


Re: pg_dump schma while excluding specific table

From
Greg Williamson
Date:
Tony --



> When I issue:
>
> pg_dump newdb > /DUMPDIR/newdb.dmp -n dev -T corgi -w -v -F c 2>
> /DUMPDIR/newdb.log
>
> I get a dump of the entire dev schema.  My goal is to dump the dev
> schema minus the corgi table.  How can I adjust my script to perform
> this function?
>
> Thanks.


Maybe the order of your arguments is causing some issues. This worked for me

  pg_dump -s -T product_feed_data staging_feed > sf.sql

Where staging_feed is that database and product_feed_data is the table I excluded:
grep product_feed_data sf.sql | grep -v product_feed_data_
COMMENT ON TABLE product_key IS 'A temporary table used to sync product_feed_data.does_exist_in_product.  ...

HTH,

Greg Williamson

Re: pg_dump schma while excluding specific table

From
Adrian Klaver
Date:
On Thursday, November 03, 2011 8:16:42 am Tony Capobianco wrote:
> When I issue:
>
> pg_dump newdb > /DUMPDIR/newdb.dmp -n dev -T corgi -w -v -F c 2>
> /DUMPDIR/newdb.log
>
> I get a dump of the entire dev schema.  My goal is to dump the dev
> schema minus the corgi table.  How can I adjust my script to perform
> this function?

 A test here worked:
pg_dump -n public -T csv_null -U postgres -Fc -f test.out  test

This is for Postgres version 9.0.4, what version are you using?

>
> Thanks.

--
Adrian Klaver
adrian.klaver@gmail.com

Re: pg_dump schma while excluding specific table

From
Tony Capobianco
Date:
I'm using 9.0.3.  I've tried several permutations of this script and
still I get a dump of the entire schema.  The corgi table is still
included when I need it excluded.

On Thu, 2011-11-03 at 12:02 -0700, Adrian Klaver wrote:
> On Thursday, November 03, 2011 8:16:42 am Tony Capobianco wrote:
> > When I issue:
> >
> > pg_dump newdb > /DUMPDIR/newdb.dmp -n dev -T corgi -w -v -F c 2>
> > /DUMPDIR/newdb.log
> >
> > I get a dump of the entire dev schema.  My goal is to dump the dev
> > schema minus the corgi table.  How can I adjust my script to perform
> > this function?
>
>  A test here worked:
> pg_dump -n public -T csv_null -U postgres -Fc -f test.out  test
>
> This is for Postgres version 9.0.4, what version are you using?
>
> >
> > Thanks.
>



Re: pg_dump schma while excluding specific table

From
Ioana Danes
Date:

>
> pg_dump newdb > /DUMPDIR/newdb.dmp -n dev -T corgi -w -v -F c 2>
> /DUMPDIR/newdb.log
>

Try: -T dev.corgi  instead of -T corgi


Re: pg_dump schma while excluding specific table

From
Adrian Klaver
Date:
On Thursday, November 03, 2011 12:54:35 pm Tony Capobianco wrote:
> I'm using 9.0.3.  I've tried several permutations of this script and
> still I get a dump of the entire schema.  The corgi table is still
> included when I need it excluded.

You may be getting bit by search path issues:

http://www.postgresql.org/docs/9.0/interactive/app-pgdump.html

"Note: The behavior of the -t switch is not entirely upward compatible with
pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables
named tab, but now it just dumps whichever one is visible in your default search
path. To get the old behavior you can write -t '*.tab'. Also, you must write
something like -t sch.tab to select a table in a particular schema, rather than
the old locution of -n sch -t tab. "

While the above shows -t the same applies to -T.


--
Adrian Klaver
adrian.klaver@gmail.com

Re: pg_dump schma while excluding specific table

From
Tony Capobianco
Date:
BINGO!

Thanks everyone.  That did the trick!

On Thu, 2011-11-03 at 12:56 -0700, Ioana Danes wrote:
>
> >
> > pg_dump newdb > /DUMPDIR/newdb.dmp -n dev -T corgi -w -v -F c 2>
> > /DUMPDIR/newdb.log
> >
>
> Try: -T dev.corgi  instead of -T corgi
>
>