PostgreSQL's Data Unloader (PDU) is an open-source recovery tool designed for situations where a PostgreSQL instance cannot be started, making normal SQL tools unavailable. It operates by reading PostgreSQL data files and WAL archives directly, without modifying the original data directory. This allows developers to recover data from corrupted or inaccessible databases while preserving the original files for forensic analysis.
- Offline metadata reconstruction: PDU can discover database, schema, and table metadata from a stopped PostgreSQL instance, rebuilding the logical structure from raw data files. This works for full-database export or targeted schema/table extraction.
- Bulk export to CSV: After metadata discovery, PDU can export single tables, schemas, or the entire database into CSV format with a single command. The CSV output is practical for inspecting recovered data or loading it into another running PostgreSQL instance.
- WAL-based row recovery: For accidental
DELETEorUPDATEoperations, PDU can reconstruct deleted rows or pre-update row versions directly from WAL records. This process uses the WAL stream — either from a replica or from archived WAL files — rather than relying on tuple remnants that might have been removed byVACUUM. The recovery window depends solely on WAL availability. - Read-only and safe: PDU never modifies the original data directory, ensuring the source data remains intact for repeated recovery attempts or legal preservation.
For developers managing PostgreSQL in production, PDU fills a critical gap when standard recovery methods fail. By enabling offline data export and precise row-level restoration from WAL archives, it reduces data loss scenarios and provides a robust fallback for disaster recovery. The tool's open-source nature invites community contributions and audits, making it a valuable addition to any PostgreSQL toolkit.