Re: pg_restore fails - Mailing list pgsql-general

From David G. Johnston
Subject Re: pg_restore fails
Date
Msg-id CAKFQuwZe1AwGsndumnG2XZ-hP39q4mXLYAy=CDL37WvuY2Le9A@mail.gmail.com
Whole thread Raw
In response to Re: pg_restore fails  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
On Sat, Mar 12, 2016 at 5:31 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
You probably should just drop the existing database and use --create by itself.

You can even use the dropdb command to avoid SQL in your script.


​This seems like it is the main problem:

# dropdb postgres
# pg_restore --create <a dump with the postgres database>

>No problems​
 

​ # pg_restore --clean --create <a dump with the postgres database>

​>public schema already exists

So both --clean and --create are attempting to create the database.

So in the example you can either use:

# pg_restore --clean -d postgres
or
# pg_restore --create -d template1

But with the later you have to "dropdb" first - if the target database already exists

With the former you have to "createdb" first - if the target database doesn't already exist.

I agree the that exit code situation should be enhanced as well.

David J.

pgsql-general by date:

Previous
From: Karsten Hilbert
Date:
Subject: Re: pg_restore fails
Next
From: "David G. Johnston"
Date:
Subject: Re: pg_restore fails