Backup & Restore - Mailing list pgsql-general

From Charlie Clark
Subject Backup & Restore
Date
Msg-id B891027A-C2E3-4DAD-995F-92290DBE7BBE@begeistert.org
Whole thread Raw
List pgsql-general
Hi,

I have a simple question that I can't find the answer to in the
documentation: how do I backup & restore a single database, ie. when
going from one cluster to another? I'm fairly comfortable with the
command line so I can create and restore backups but things do not
always work as expected.

pg_dump -U postgres  -f my_database.dmp -F c my_database

now I want to restore this database to another system where a
database with the same name already exists (from production to
development):

According to the documentation the options -c and -a can be set on
pg_restore

ie.,
pg_restore -U postgres -c -d psytec psytec.dmp

should drop all the tables before recreating them but I get a load of
errors:
pg_restore: [archiver (db)] Error from TOC entry 1949; 2620 297386
TRIGGER RI_ConstraintTrigger_297386 postgres

using -a to restore data only means fewer errors as pg_restore exits
on the first error

Is the only way to drop the target database and recreate an empty
one? Or am I simply misreading the docs?

Thanks very much for any help.

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226




pgsql-general by date:

Previous
From: "Jasbinder Singh Bali"
Date:
Subject: new line in psotgres
Next
From: Michael Glaesemann
Date:
Subject: Re: pg_dump of only the structure from a client such as ruby