Re: Recover rows deleted

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Alejandro Carrillo <fasterzip(at)yahoo(dot)es>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Recover rows deleted
Date: 2012-05-29 20:53:20
Message-ID: 1338324800.28651.5.camel@sussancws0025
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 2012-05-28 at 19:24 +0100, Alejandro Carrillo wrote:
> Hi,
>
>
> ¿How I can recover a row delete of a table that wasn't vacuummed?
> I have PostgreSQL 9.1 in Windows XP/7.

The first thing to do is shut down postgresql and take a full backup of
the data directory, including any archived WAL you might have (files in
pg_xlog). Make sure this is done first.

Next, do you have any backups? If you have a base backup from before the
delete, and all the WAL files from the time of the base backup until
now, then you can try point-in-time recovery to the point right before
the data loss:

http://www.postgresql.org/docs/9.1/static/continuous-archiving.html

If not, are we talking about a single row, or many rows? If it's a
single row you might be able to do some manual steps, like examining the
pages to recover the data.

Another option is to try pg_resetxlog (make sure you have a safe backup
first!):

http://www.postgresql.org/docs/9.1/static/app-pgresetxlog.html

And try setting the current transaction ID to just before the delete
ran. Then you may be able to use pg_dump or otherwise export the deleted
rows.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message hubert depesz lubaczewski 2012-05-29 21:33:20 Re: Recover rows deleted
Previous Message Tom Lane 2012-05-29 17:42:42 Re: Strong slowdown on huge tables