Postgresql – Trouble recovering data from corrupted PostgreSQL tables

corruptionpostgresqlrestore

I'm trying to recover my database after a recent corruption of the same. Now I have two tables that are really giving me trouble.

When I do select count(*) One table returns:

ERROR: could not access status of transaction 2619431010
DETAIL: Could not open file "pg_clog/09C2": No such file or directory.

The other one returns:

ERROR: invalid page header in block 94206 of relation
base/11974232/11975439

Is there a way I can work around and get my data back?

Best Answer

About this error:

ERROR: invalid page header in block 94206 of relation base/11974232/11975439

You could issue SET zero_damaged_pages TO ON and retry. It will not rewrite any page to disk, just in memory. Assuming it works, the idea is to run COPY bad TO 'file' to dump as much valuable data as possible.

(that's also assuming that 11975439 is the OID of a table, not an index. If it's an index, you may just drop it).