Re: pg_restore and the -C flag

From: Keith <keith(at)keithf4(dot)com>
To: John Scalia <jayknowsunix(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: pg_restore and the -C flag
Date: 2019-07-17 13:19:09
Message-ID: CAHw75vuaUiGJk3eXarVUnFztc=JSB-bhjGukqw9==ULhdAHrDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Jul 17, 2019 at 8:43 AM John Scalia <jayknowsunix(at)gmail(dot)com> wrote:

> Hi all,
>
> From what I’m reading on www.postgresql.org, the -C option for pg_restore
> is supposed to create the database before restoring into it, but here’s my
> command line:
>
> pg_restore -p 5432 -C -d restored_db recovery.dmp
>
> The dmp file was created with pg_dump using
>
> pg_dump -p 5432 -F c orig_db > recovery.dmp.
>
> Pg_restore errors saying the database does not exist. Yes, I know that
> port 5432 is the default, but not all of our databases are. So, do I have
> any options wrong with either utility? Or why is this happening? I’m just
> trying to document a recovery procedure and testing my documentation.
> —
> Jay
>
> Sent from my iPhone
>
>
I suspect the name your feeding to -d is the one you're trying to create?
You still have to tell pg_restore to connect to a database that actually
exists so it can log in to create one. So try passing "postgres" to the -d
option. Or connect as you usually do with psql and run \l to see what
databases already exist and connect to one of those.

Keith

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message John Scalia 2019-07-17 13:51:08 Re: pg_restore and the -C flag
Previous Message John Scalia 2019-07-17 12:43:43 pg_restore and the -C flag