overwrote THE 'postgres' database - how to recover

From: "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: overwrote THE 'postgres' database - how to recover
Date: 2019-09-04 16:51:04
Message-ID: b6cf0e1beb6cb22012a7199bbb95ab91.squirrel@webmail.harte-lyne.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I was experimenting with creating a copy of an existing database from
a pg_dump sql backup file. I made an misake in failing to delimit an
environment variable and in consequence I issued this command as user
postgres:

I should have used:

gunzip < "$APP_DBNAME".pgsql.gz | pg_restore --create --clean
--user=postgres --dbname="$APP_DBNAME"_copy && vacuumdb
--user=postgres --full --analyze "$APP_DBNAME"_copy

But, instead I did this:

gunzip < $APP_DBNAME.pgsql.gz | pg_restore --create --clean
--user=postgres --dbname=$APP_DBNAME_copy && vacuumdb
--user=postgres --full --analyze $APP_DBNAME_copy

which resulted in this:

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?

--
*** e-Mail is NOT a SECURE channel ***
Do NOT transmit sensitive data via e-Mail
Do NOT open attachments nor follow links sent by e-Mail

James B. Byrne mailto:ByrneJB(at)Harte-Lyne(dot)ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Guillaume Lelarge 2019-09-04 19:52:13 Re: overwrote THE 'postgres' database - how to recover
Previous Message Jeff Janes 2019-09-01 16:58:15 Re: Blocking clients based on application name?