Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 07C786500D9 for ; Mon, 14 Jul 2008 11:47:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 61813-01 for ; Mon, 14 Jul 2008 11:47:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 55DBB650054 for ; Mon, 14 Jul 2008 11:47:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m6EElRUu008260; Mon, 14 Jul 2008 10:47:27 -0400 (EDT) To: Paul Libbrecht cc: pgsql-admin@postgresql.org Subject: Re: accidental drop table recoverable? In-reply-to: <53CDF98F-0AE1-49ED-A2A3-C3B1E2AF2E2E@activemath.org> References: <53CDF98F-0AE1-49ED-A2A3-C3B1E2AF2E2E@activemath.org> Comments: In-reply-to Paul Libbrecht message dated "Mon, 14 Jul 2008 15:13:21 +0200" Date: Mon, 14 Jul 2008 10:47:27 -0400 Message-ID: <8259.1216046847@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/121 X-Sequence-Number: 29731 Paul Libbrecht writes: > right now we experienced the loss of backups (due to wrong > communication) and a list of accidental drop table statements (due to > wrong database choice). Ouch. > We sure have clues how to avoid that in the future but right now we do > not seem to find the solution to actually rollback this accidental > drop table. You can't really "rollback" a DROP TABLE --- that corresponds directly to a filesystem remove() call, and no amount of fooling around with the database state will undo that. If you have filesystem tools that will resurrect the deleted files for you, you could probably put them back into the database. My inclination would be not to try to "roll back" anything, but create new tables with the identical column sets to the old ones (but no indexes) and then rename the recovered files into place to match the new tables' relfilenode values. After which, a dump and reload would be prudent to make sure everything's really kosher. (Actually, copying the data into newly created tables should be enough for that.) regards, tom lane