Re: Avoid duplicated rows when restoring data from pg_dumpall ?? - Mailing list pgsql-admin

From Tom Lane
Subject Re: Avoid duplicated rows when restoring data from pg_dumpall ??
Date
Msg-id 11581.1251125232@sss.pgh.pa.us
Whole thread Raw
In response to Avoid duplicated rows when restoring data from pg_dumpall ??  (Pablo Alonso-Villaverde Roza <pavroza@gmail.com>)
Responses Re: Avoid duplicated rows when restoring data from pg_dumpall ??  (Pablo Alonso-Villaverde Roza <pavroza@gmail.com>)
List pgsql-admin
Pablo Alonso-Villaverde Roza <pavroza@gmail.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

pgsql-admin by date:

Previous
From: Geoffrey
Date:
Subject: Re: 32bit and 64bit cluster with shared data silo
Next
From: james bardin
Date:
Subject: Re: warm standby and reciprocating failover.