Keolo Blog

How to Repair a Corrupted PostgreSQL Database

If PostgreSQL fails to start with these errors:

LOG:  could not read from log file 0, segment 73, offset 0: No such file or directory
LOG:  invalid primary checkpoint record
PANIC:  could not locate a valid checkpoint record
LOG:  startup process (PID 1169) was terminated by signal 6: Abort trap
LOG:  aborting startup due to startup process failure

You can try to repair the database cluster using this command:

pg_resetxlog -f /ClusterPath

Then start PostgreSQL again. If it starts properly, you can dump the database and recreate a new one.

← Read other blog posts