This is PDU's most powerful feature. When tables are dropped or truncated, PostgreSQL marks the space as free but doesn't immediately overwrite the data. PDU can find and recover this data through disk fragment scanning.
The only publicly documented practical method to restore DROP TABLE or TRUNCATE without backups.
After a DROP/TRUNCATE incident, the first PDU recovery action must be to preserve the disk image. Before running b;, use, scan drop, meta tab, editing tab.config, or any scan and recovery command, stop writes whenever possible and complete only the required disk configuration below.
The following command identifies the filesystem device that contains the PostgreSQL data directory. Replace /home/pg/data with the actual PGDATA path. df -h displays the filesystem for that directory, while awk 'NR>1 {print $1}' skips the header and prints the first column. The resulting device path, such as /dev/mapper/data-lv, is the value to use for DISK_PATH.
# Replace /home/pg/data with the actual PGDATA path.# Print the filesystem device containing PGDATA and use it as DISK_PATH.[root@node1 ~]# df -h /home/pg/data | awk 'NR>1 {print $1}'/dev/mapper/data-lv# Update pdu.inivim pdu.ini#PostgreSQL Data DirectoryPGDATA=/home/pg/data/#PostgreSQL Archive DirectoryARCHIVE_DEST=/home/pg/wal_arch#Disk for dropScan to scanDISK_PATH=/dev/mapper/data-lv#Number of data blocks to skip during dropScanBLOCK_INTERVAL=20#All PostgreSQL data directories on DISK_PATH, comma-separatedPGDATA_EXCLUDE=/home/pg/data,/home/pg12/data,/home/pg14/data
PDU.public=# p isomode on;PDU.public=# ds idx;▌ Starting index retrieval● Existing data pages will be excluded during index retrievalExcluding file data pages under directory </home/pg/data/>Excluding file data pages under directory </home/pg/data/pg_wal>Excluding file data pages under directory </home/pg/data/base>Excluding file data pages under directory </home/pg/data/base/16384>Excluding file data pages under directory </home/pg/data/global>... (more directories) ...=== Disk Scan Process Monitor ===Thread 0: 98.26% (Offset: 34288435200/34894512128) Pages: 30879Thread 1: 100.00% (Offset: 69789024256/69789024256) Pages: 0Total: 99.13% Pages: 30879 Time Elapsed: 111.2sEstimating Time Left: 1.0 Seconds# Generated files:restore/.dsiso/idxrestore/.dsiso/pgiso
Only after the disk index and ISO image have been verified may you initialize metadata and retrieve the table structure. If WAL archiving is enabled, PDU can automatically retrieve it from archived WAL files using the scan drop command.
The scanned tables are saved in the restore database. Switch to it and use meta tab to export the table structure:
mydb.public=# use restore;────────────────────────────────────────│ Schema │ Tab Num │────────────────────────────────────────│ public │ 1 │────────────────────────────────────────restore.public=# meta tab gp_business_event;gp_business_event varchar,bpchar,varchar,varchar,varchar,varchar,varchar,date,varchar,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,timestamptz,bpchar,varcharCompleted, imported 1 dropscan-capable table objects in total
Or use scan drop to batch generate, then use meta sch schema_name to add all tables in a schema:
restore.public=# meta sch public;
Completed, imported 5 dropscan-capable table objects in total
Q: What if disk fragments have been overwritten?
After DISK_PATH and the complete PGDATA_EXCLUDE list are configured, the standard workflow saves candidate pages during the index phase. Always enable isomode before running ds idx:
PDU.public=# p isomode on;
PDU.public=# ds idx; -- This saves page images
-- Later, use iso mode for scanning:
PDU.public=# ds iso;
This allows recovery even if original disk fragments are later overwritten.
Q: What does 'Suspected gibberish' mean in the output?
This indicates records that PDU found but suspects may be corrupted or contain invalid data. These records are still included in the output but should be reviewed carefully.
Q: How long does the scanning process take?
Scanning time depends on disk size and the BLOCK_INTERVAL setting. A smaller BLOCK_INTERVAL provides more comprehensive disk coverage but is slower. For faster scanning on large disks, increase the BLOCK_INTERVAL value.