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

Luca Ferrari <[email protected]>
Newsgroups gmane.comp.db.postgresql.admin
Message-ID <CAKoxK+7w1gWuKu2X6ti83x32q4Yj85B6MLvtgJwXi4ocV8Ae7g@mail.gmail.com>
On Wed, Sep 4, 2019 at 9:52 PM Guillaume Lelarge <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.