Re: Avoid duplicated rows when restoring data from pg_dumpall ??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pablo Alonso-Villaverde Roza <pavroza(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Avoid duplicated rows when restoring data from pg_dumpall ??
Date: 2009-08-24 14:47:12
Message-ID: 11581.1251125232@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Pablo Alonso-Villaverde Roza <pavroza(at)gmail(dot)com> writes:
> I'm getting duplicated rows in some of my tables when I try to restore data
> from a dump file generated with 'pg_dumpall'.

Probably all of them, actually ...

> The only "way" I have found to solve this problem is deleting my database
> before restoring the data, so everything is 're-created' in the restore
> process without generating duplicated rows.

A pg_dumpall script expects to be restored into an empty cluster. This
is not a bug.

> I thought, that the "-c" flag on pg_dumpall would force a DROP of any
> previous data structures on the server but...it looks like it doesn't work
> as I expected and ...when I restore data I get duplicated rows.

The -c flag should cause the script to DROP all your databases first.
But that switch has been known to have bugs in the past, and in any case
it could fail if there are other sessions connected to those databases.
Did you pay attention to whether the restore reported any errors?
What PG version is this?

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message james bardin 2009-08-24 15:34:18 Re: warm standby and reciprocating failover.
Previous Message Geoffrey 2009-08-24 14:35:09 Re: 32bit and 64bit cluster with shared data silo