If you have backups, simply restore them.
If not, you just found out why regular backups are needed. PostgreSQL cannot do anything there if the hardware is incorrect.
In addition, if you ever find yourself in this situation again, first stop PostgreSQL and take a full backup of the entire level - all table spaces, WAL, etc. So you have a famous starting point.
So - if you still want to recover some data.
- Try resetting individual tables. Get what you can this way.
- Drop indexes if they cause problems.
- Dump table partitions (id = 0..9999, 1000..19999, etc.) - this way you can determine where some rows may get corrupted and reset all smaller partitions to restore what is still good.
- Try to reset only certain columns - large text values are stored out of turn (in tables with toasts), so you can avoid extracting the rest of the data.
- If you have corrupted system tables, you get a lot of work.
This is a lot of work, and then you will need to go through and check what you have restored, and try to find out what is missing / incorrect.
There are many things you can do (creating empty blocks in some cases may allow you to dump partial data), but they are more and more complicated and if the data is not particularly valuable, it’s not worth the effort.
The key message to take away is to make sure you make regular backups and make sure they work.
Richard Huxton Jun 14 '12 at 15:17 2012-06-14 15:17
source share