This guide covers recovering the original data before accidental UPDATE operations. PDU extracts the pre-update values from WAL archive files, allowing you to restore data that was incorrectly modified.
Critical Prerequisites
WAL archiving must be enabled
The principle is the same as deleted records recovery - extracting data from WAL files.
Ensure WAL files are archived after the update
Run these commands after the accidental update:SELECT pg_switch_wal(); CHECKPOINT;
Same as deleted records recovery, configure both PGDATA and ARCHIVE_DEST:
[root@node1 pdu]# cat pdu.ini#PostgreSQL Data DirectoryPGDATA=/home/pg/data/#PostgreSQL Archive DirectoryARCHIVE_DEST=/home/pg/wal_arch#Disk for dropScan to scanDISK_PATH=#Number of data blocks to skip during dropScanBLOCK_INTERVAL=20
PDU.public=# use mydb;┌────────────────────────────────────────┐│ Schema │ Tab Num │├────────────────────────────────────────┤│ public │ 1071 │└────────────────────────────────────────┘mydb.public=#
The scan command works the same way, but now scans for UPDATE operations instead of DELETE:
mydb.public=# scan t_user_profiles;Scanning updated Records for table<t_user_profiles>...▌ Scanning Archived Wal Directory StartWal: 000000010000000500000010 EndWal: 00000001000000050000002F▌ Time Range Restore Mode [Displayed all within Time Range]────────────────────────────────────────▌ End of Scanning, current time range: Start: 2025-03-10 14:22:15.123456 EST End: 2025-03-10 14:35:42.789012 EST▌ Time Range Details┌─────────────────────────────────────────────────────────┐ Start Time: 2025-03-10 14:22:15.123456 EST End Time: 2025-03-10 14:35:42.789012 EST LSN: 5/10A23450 - 5/2F8B1230 Recommended startwal: 000000010000000500000010 Recommended endwal: 00000001000000050000002F -------------------.-------------------- ● Datafile OID: 156789 ● Toastfile OID: 0 ● Records updated in the Time Range: 2500└─────────────────────────────────────────────────────────┘Execution Time 15.32 seconds
When a WHERE clause was missing or incorrect, causing unintended rows to be updated. Use Time Range Mode to recover all affected rows.
Specific Transaction Rollback
When you need to undo changes from a specific application operation or user action. Use Transaction Mode to target that exact transaction.
Data Auditing
When you need to see what values existed before certain changes were made, for compliance or debugging purposes.
Tip
PDU supports both Time Range Mode and Transaction Mode for UPDATE recovery. Transaction Mode is particularly useful when you need to recover only specific transactions among many changes.