pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_restore and the -C flag
3+ messages / 2 participants
[nested] [flat]

* pg_restore and the -C flag
@ 2019-07-17 12:43  John Scalia <jayknowsunix@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: John Scalia @ 2019-07-17 12:43 UTC (permalink / raw)
  To: pgsql-admin

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_restore and the -C flag
@ 2019-07-17 13:19  Keith <keith@keithf4.com>
  parent: John Scalia <jayknowsunix@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Keith @ 2019-07-17 13:19 UTC (permalink / raw)
  To: John Scalia <jayknowsunix@gmail.com>; +Cc: pgsql-admin

On Wed, Jul 17, 2019 at 8:43 AM John Scalia <jayknowsunix@gmail.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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_restore and the -C flag
@ 2019-07-17 13:51  John Scalia <jayknowsunix@gmail.com>
  parent: Keith <keith@keithf4.com>
  0 siblings, 0 replies; 3+ messages in thread

From: John Scalia @ 2019-07-17 13:51 UTC (permalink / raw)
  To: Keith <keith@keithf4.com>; +Cc: pgsql-admin

Thanks, Keith. I reread the documentation, and I guess that earlier, I wasn’t awake enough to comprehend it. It’s all working now.

Sent from my iPhone

> On Jul 17, 2019, at 9:19 AM, Keith <keith@keithf4.com> wrote:
> 
> 
> 
>> On Wed, Jul 17, 2019 at 8:43 AM John Scalia <jayknowsunix@gmail.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
> 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-07-17 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 12:43 pg_restore and the -C flag John Scalia <jayknowsunix@gmail.com>
2019-07-17 13:19 ` Keith <keith@keithf4.com>
2019-07-17 13:51   ` John Scalia <jayknowsunix@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox