pg_restore --clean failing due to dependancies

From: "Arnaud L(dot)" <arnaud(dot)listes(at)codata(dot)eu>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: pg_restore --clean failing due to dependancies
Date: 2016-11-15 15:11:44
Message-ID: b3690957-fd8c-6def-d3ec-e589887dd0f1@codata.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

Postgresql 9.3.14 on Windows.
Hi am making daily backups of a database and omitting two schemas from
the dump (and the public schema). Those schemas are read-only and have
no dependancy with the rest of the database.
My command is :
pg_dump -h pgsql1 -U postgres -b -Fc -E UTF8 -N public -N osm -N osm2 -f
"D:\db.dump" db1

(I also omit "public" because we use postgis, so it's cleaner for me to
dump without the public schema, then start from an empty database and do
a "create extension postgis" before restoring)

I can successfully restore this dump without any error in an empty database.

Now, I would like to restore this dump in a database where the
aforementioned schemas have been loaded. So i would like to do a
pg_restore --clean, in order two preserve those two schemas (and the
public one), and to restore everything else.
The restore fails on a lot of statements, complaining about dependencies.
For instance, "cannot drop rule _RETURN on view myview1 because view
myview1requires it". Or "cannot drop constraint mypkey on table my table
because other objects depend on it [list of foreign keys]".

My command is :
pg_restore -U postgres -h pgsql1 --clean -d db1 "D:\db.dump"

I thought that pg_restore was supposed to reorder the objects to honor
dependencies ? How can I get this right ?

Thanks for your help !
Cheers

--
Arnaud

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-11-15 15:13:27 Re: Fwd: Mail to be posted in PostgreSQL community
Previous Message Adrian Klaver 2016-11-15 15:02:42 Re: Fwd: Mail to be posted in PostgreSQL community