Re: refreshing a database with pg_dump and psql

From: "Rossi, Maria" <maria(dot)rossi(at)us(dot)pgds(dot)com>
To: 'Jan Lentfer' <Jan(dot)Lentfer(at)web(dot)de>, "'David G(dot) Johnston'" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "'pgsql-admin(at)postgresql(dot)org'" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: refreshing a database with pg_dump and psql
Date: 2015-05-27 00:44:32
Message-ID: d19fbb1d0c48428eb86b78b8e5bdd6f4@DC01PXMBP003.jacksonnational.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I will try the pg_restore –cC or drop the database first.
Thank you all for the quick response.

Maria A Rossi
Database Administration
PGDS (US)
email: maria(dot)rossi(at)us(dot)pgds(dot)com<mailto:maria(dot)rossi(at)us(dot)pgds(dot)com>
cell phone: 517.256.4392
work phone: 517.367.3099
work phone extension: 23099

From: Jan Lentfer [mailto:Jan(dot)Lentfer(at)web(dot)de]
Sent: Tuesday, May 26, 2015 5:41 PM
To: David G. Johnston
Cc: Rossi, Maria; pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] refreshing a database with pg_dump and psql

Am 26.05.2015 um 23:36 schrieb David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com<mailto:david(dot)g(dot)johnston(at)gmail(dot)com>>:
On Tue, May 26, 2015 at 2:27 PM, Jan Lentfer <Jan(dot)Lentfer(at)web(dot)de<mailto:Jan(dot)Lentfer(at)web(dot)de>> wrote:

Am 26.05.2015 um 23:09 schrieb Rossi, Maria <maria(dot)rossi(at)us(dot)pgds(dot)com<mailto:maria(dot)rossi(at)us(dot)pgds(dot)com>>:
Hi,

I have a database that was created from a ‘pg_dump –C’. No problems there. Then I ran the pg_dump again, this time without the –C. and tried to load it. But got a bunch of ‘object already exist’.
Can’t I refresh an existing database from a plain pg_dump? Is there an option that I have to use?
Thanks.

Check the pg_restore manual. There is a "clean" option when using the custom format. I think this is what you are looking for.

​Or just inject a "DROP DATABASE ..." into the equation somewhere.

pg_restore -cC will do that, too.

Jan

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Charles Sprickman 2015-05-27 05:02:24 autovacuum was not vacuuming
Previous Message Wei Shan 2015-05-27 00:38:57 Re: refreshing a database with pg_dump and psql