Postgres12 - Confusion with pg_restore - Mailing list pgsql-general

From Laura Smith
Subject Postgres12 - Confusion with pg_restore
Date
Msg-id swGhpjlYbJk4-gy0O7mkmfijTCHp8W3-2aXmb5xCXnMXBfwUzCT87YCWcmkCPfYNvyLqHoV8sMsd6wBePEZShGBSBDQ6XITJlNrpdns3IAM=@protonmail.ch
Whole thread Raw
Responses Re: Postgres12 - Confusion with pg_restore  (Christophe Pettus <xof@thebuild.com>)
List pgsql-general
According to the all-mighty manual (https://www.postgresql.org/docs/current/app-pgrestore.html), life is supposed to be
assimple as: 

"To drop the database and recreate it from the dump:
$ dropdb mydb
$ pg_restore -C -d postgres db.dump"

The reality seems to be somewhat different ?

sudo -u postgres pg_restore -v -C -d foobar 4_foobar_pgdump_Fc
pg_restore: connecting to database for restore
pg_restore: error: connection to database "foobar" failed: FATAL:  database "foobar" does not exist

So I thought I would try to create the database manually first (CREATE DATABSE ....).  That made pg_restore even more
angry:

sudo -u postgres pg_restore -C -d foobar 4_foobar_pgdump_Fc
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3088; 1262 43395 DATABASE foobar postgres
pg_restore: error: could not execute query: ERROR:  database "foobar" already exists
Command was: CREATE DATABASE foobar WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_GB.UTF-8' LC_CTYPE =
'en_GB.UTF-8';
                                                                                                pg_restore: warning:
errorsignored on restore: 1 




pgsql-general by date:

Previous
From: Koen De Groote
Date:
Subject: Re: Index no longer being used, destroying and recreating it restores use.
Next
From: Christophe Pettus
Date:
Subject: Re: Postgres12 - Confusion with pg_restore