Re: overwrote THE 'postgres' database - how to recover

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: byrnejb(at)harte-lyne(dot)ca, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: overwrote THE 'postgres' database - how to recover
Date: 2019-09-05 07:01:07
Message-ID: CAKoxK+7w1gWuKu2X6ti83x32q4Yj85B6MLvtgJwXi4ocV8Ae7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Sep 4, 2019 at 9:52 PM Guillaume Lelarge <guillaume(at)lelarge(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2019-09-05 08:21:46 Re: Version 11 partitioning: Constraint exclusion vs Partition Pruning
Previous Message Mark Steben 2019-09-04 20:15:04 Version 11 partitioning: Constraint exclusion vs Partition Pruning