Re: pg_dump: what is advantage with schema and data dumps?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Anony Mous" <A(dot)Mous(at)shaw(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump: what is advantage with schema and data dumps?
Date: 2004-09-24 18:40:48
Message-ID: 1506.1096051248@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Anony Mous" <A(dot)Mous(at)shaw(dot)ca> writes:
> I've seen in previous posts that recommended practice for database backup is
> to run the dump utility twice. Once for schema only and a second time for
> data only (I think).

I don't know who recommended that, but I sure wouldn't do it that way.

If you do do it that way then the restore will be slow, at least if you
have any indexes or foreign keys. It's better to load the data first
and then create indexes/verify foreign keys. pg_dump does do things in
that order if you use a single dump, but obviously it cannot if you dump
schema and data separately.

What I *would* recommend is a single dump in either -Fc or -Ft mode.
The reason for this is that if needed, you can use pg_restore's options
to alter the restore order, which can get you out of trouble if you run
into one of the various pg_dump bugs about dumping related objects in
the wrong order. (I think said bugs are finally all fixed for 8.0, but
they are a fact of life in released PG versions, so you should be
prepared to deal with 'em.)

If you use a text dump then you have to be willing to fix any ordering
problems by editing the dump file ... which can be a tad unwieldy if
it's a big dump.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Amin Abdulghani 2004-09-24 18:41:27 Re: Removed and then missing pg_clog file
Previous Message Paul Tillotson 2004-09-24 18:39:11 Re: books/sites for someone really learning PG's advanced