Recover Data from Disk Fragments

When relation files or directories are lost but PostgreSQL pages remain on disk, freeze sources first and choose a recovery method from available evidence. The following sections describe fragment sources, page recovery and unresolved-result handling in detail.


I. Preserve the Disk Image Immediately

Use Probe when stable relation files are available. To preserve surviving pages from media, configure DISK_PATH, PGDATA_EXCLUDE and scan ranges as described in Protect the Recovery Scene, then run ds idx;. Image saving is enabled by default.

param isomode on;
ds idx;

See scene preservation and disk-source preparation.

restore/.dsiso/pgiso stores the page image, and the sibling idx retains original disk offsets and continuous-page relationships. Preserve both. Scan completion means the selected range was processed, not that business data has been recovered.


II. Choose the Recovery Method

  • Relation files survive with unknown mappings: use Probe/ProbeBatch.
  • With existing configuration and indexes: use traditional DropScan ds iso, ds toast and ds copy paths.
  • With only a page image and DDL: create PDUPlan and run RecoverISO.

See unknown-data-file identification.

See page-image recovery.


III. Inspect Page and Tuple Evidence

When first-pass recovery has retained evidence, inspect pages, tuples and layout interpretations read-only. Replace example numbers with actual IDs from the current report, specifying tuple and plan together.

ds recoveriso --inspect /recovery-work/first-pass --page=123;
ds recoveriso --inspect /recovery-work/first-pass --page=123 --tuple=1 --plan=2;

This command reads existing evidence without opening the image or exported CSV. Successful layout decoding does not establish table attribution.


IV. Continue Historical Layout Analysis

ds recoveriso --deepen /recovery-work/first-pass /recovery-work/second-pass --mode=relaxed;

Second-pass analysis uses a new workspace, reusing existing interpretations, then saved pages, and targeted image reads when needed. Continuous historical prefixes and multiple interpretations remain subject to confirmation without fabricated missing fields.


V. Resolve Attribution from Explicit Evidence

Prepare a rules file and execute --attribute only after attribution evidence has been explicitly reviewed. Rule format and source locations must match the current workspace. Identical table names, fields or similar counts do not replace business evidence.

ds recoveriso --attribute /recovery-work/first-pass /recovery-input/accepted-rules.tsv /recovery-work/attribution;

The command reuses saved interpretations by location, retaining evidence and unknown states without automatic database import. Unattributed fragments and unresolved TOAST dependencies remain retained.


Output Files

Recovery records include original pages, source locations, possible decodes and unresolved problems. Count complete records, retained historical prefixes, uncertain table mappings and missing external values separately. Adding them together does not give a count of unique business records.

After export, record native success and failure counts and original errors reported by PDU, and retain checkpoints. Resume uses native records and file metadata such as existence and size without rereading or validating exported data.

PostgreSQL 文档