pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: James B. Byrne <byrnejb@harte-lyne.ca>
To: pgsql-admin@lists.postgresql.org
Subject: overwrote THE 'postgres' database - how to recover
Date: Wed, 4 Sep 2019 12:51:04 -0400
Message-ID: <b6cf0e1beb6cb22012a7199bbb95ab91.squirrel@webmail.harte-lyne.ca> (raw)

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@Harte-Lyne.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






view thread (4+ messages)  latest in thread

Message-ID: <b6cf0e1beb6cb22012a7199bbb95ab91.squirrel@webmail.harte-lyne.ca>
Permalink:  ../b6cf0e1beb6cb22012a7199bbb95ab91.squirrel@webmail.harte-lyne.ca/
Also on:    postgresql.org/message-id/b6cf0e1beb6cb22012a7199bbb95ab91.squirrel@webmail.harte-lyne.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: byrnejb@harte-lyne.ca, pgsql-admin@lists.postgresql.org
  Subject: Re: overwrote THE 'postgres' database - how to recover
  In-Reply-To: <b6cf0e1beb6cb22012a7199bbb95ab91.squirrel@webmail.harte-lyne.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox