Postgres12 - Confusion with pg_restore

From: Laura Smith <n5d9xq3ti233xiyif2vp(at)protonmail(dot)ch>
To: postgre <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Postgres12 - Confusion with pg_restore
Date: 2020-06-05 18:20:48
Message-ID: swGhpjlYbJk4-gy0O7mkmfijTCHp8W3-2aXmb5xCXnMXBfwUzCT87YCWcmkCPfYNvyLqHoV8sMsd6wBePEZShGBSBDQ6XITJlNrpdns3IAM=@protonmail.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

According to the all-mighty manual (https://www.postgresql.org/docs/current/app-pgrestore.html) life is supposed to be as simple 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: errors ignored on restore: 1

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2020-06-05 18:23:39 Re: Postgres12 - Confusion with pg_restore
Previous Message Koen De Groote 2020-06-05 15:34:34 Re: Index no longer being used, destroying and recreating it restores use.