Re: overwrote THE 'postgres' database - how to recover - Mailing list pgsql-admin

From Luca Ferrari
Subject Re: overwrote THE 'postgres' database - how to recover
Date
Msg-id CAKoxK+7w1gWuKu2X6ti83x32q4Yj85B6MLvtgJwXi4ocV8Ae7g@mail.gmail.com
Whole thread Raw
In response to Re: overwrote THE 'postgres' database - how to recover  (Guillaume Lelarge <guillaume@lelarge.info>)
List pgsql-admin
On Wed, Sep 4, 2019 at 9:52 PM Guillaume Lelarge <guillaume@lelarge.info> wrote:
>> gunzip < hll_redmine.pgsql.gz  |  pg_restore --create --clean
>> --user=postgres --dbname=  &&  vacuumdb --user=postgres --full
>> --analyze
>>
>> Which caused the postgres database to be overwritten with
>> hll_redmine.pgsql.gz.  Is there an easy way to get this back or do I
>> have to reinitialise the whole thing?
>>
>
> Well, you can connect to some database (but not postgres), drop the postgres one, and create it again.

I would connect to template1, alter database postgres rename to
<whatever> and then create a new postgres database.
It is interesting to see that pg_restore defaults to username database
even if there's a dbname command line option. I didn't know that (and
I'm not sure is something "cool").

Luca



pgsql-admin by date:

Previous
From: Mark Steben
Date:
Subject: Version 11 partitioning: Constraint exclusion vs Partition Pruning
Next
From: Laurenz Albe
Date:
Subject: Re: Version 11 partitioning: Constraint exclusion vs PartitionPruning