Physical PostgreSQL recovery
中文

PostgreSQL Data Recovery for Corrupted or Offline Databases

PDU (PostgreSQL Data Unloader) reads copied PostgreSQL physical files and WAL directly. It is built for incidents where the server will not start, pg_dump cannot access the data, a table file is damaged, rows were changed by mistake, or no usable backup remains.

This is a salvage workflow, not a replacement for backups. PDU works offline, leaves the original evidence untouched, reports decode failures, and exports the rows that can be recovered from surviving heap, TOAST, catalog, and WAL data.

Technical review by Zhang Chen, PostgreSQL data recovery specialist and PDU maintainer. Updated July 27, 2026.

Choose recovery by incident, not by tool name

PostgreSQL backup restore, point-in-time recovery, and physical data salvage solve different problems. A healthy backup chain is always the first choice. Physical PG data recovery begins when the normal database and backup paths are unavailable or incomplete.

IncidentProtect firstRelevant PDU path
The server runs and a verified backup existsUse PostgreSQL restore or PITR firstPDU is normally unnecessary
PostgreSQL cannot start or pg_dump cannot read the dataPreserve and clone PGDATAOffline physical-file extraction
A table file contains damaged pagesWork from a copy and preserve the DDLPage-level heap and TOAST recovery
DELETE or UPDATE must be reversedPreserve the relevant WAL rangeWAL-based row reconstruction
DROP or TRUNCATE happened without a backupStop writes and image the storageFragment scan if pages still survive

What can be measured

  • • Rows decoded from each data file and rows rejected during parsing
  • • Heap records, TOAST values, and table structures that can be reconstructed
  • • WAL records available for a specific DELETE or UPDATE time window
  • • Exported CSV row counts before the result is imported into an isolated database

What no recovery tool can promise

  • • Data from disk sectors that are physically destroyed or already overwritten
  • • Complete large-object recovery when the required TOAST files are missing
  • • Accurate row ownership when table metadata and DDL cannot be reconstructed
  • • Guaranteed DROP or TRUNCATE recovery after continued writes reuse the blocks

PostgreSQL data recovery FAQ

What is PostgreSQL data recovery?

PostgreSQL data recovery is the process of salvaging usable rows when normal SQL access, pg_dump, backup restore, or point-in-time recovery cannot solve the incident. Physical recovery works from copied PostgreSQL data files, WAL, and known table structures instead of relying on a healthy running server.

Can PostgreSQL data be recovered without a backup?

Sometimes. If the relevant heap, TOAST, catalog, or WAL bytes still exist, PDU can attempt to decode and export them. Recovery is not possible for storage that has been physically destroyed or overwritten, and no tool can guarantee every row.

Can PDU recover a database from a PGDATA directory?

PDU can register and analyze a copied PostgreSQL database directory without starting the original cluster. Results depend on the PostgreSQL version, the condition of system catalogs and table files, and whether the required TOAST and tablespace files are present.

Does PDU modify the original PostgreSQL files?

The recovery workflow is based on offline, read-only analysis. The original server or disk should be stopped and preserved; all scanning and export work should be performed on a verified copy or storage image.

What should be collected before recovery starts?

Preserve the exact PostgreSQL major version, PGDATA, tablespaces, archived WAL, server logs, and table DDL if available. Record the incident time and stop further writes so that recoverable pages are not overwritten.

Is PostgreSQL data recovery guaranteed?

No. The outcome is determined by what bytes remain and whether their metadata can be reconstructed. PDU reports parsing failures and exports recoverable data so the result can be measured rather than assumed.

Start with preserved evidence

Before testing any PostgreSQL recovery tool, keep the original disk untouched and work from a verified copy. Then select the guide that matches the incident and validate exported row counts in an isolated database.