Re: pg_restore fails

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_restore fails
Date: 2016-03-13 00:44:19
Message-ID: CAKFQuwZe1AwGsndumnG2XZ-hP39q4mXLYAy=CDL37WvuY2Le9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Mar 12, 2016 at 5:31 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-03-13 00:49:56 Re: pg_restore fails
Previous Message Karsten Hilbert 2016-03-13 00:43:51 Re: pg_restore fails