DocsFull Usage GuideCommand Reference

Command Reference

Complete reference for all PDU commands

Syntax Rules

All commands must end with a semicolon (;). E.g.: b; , \l; , unload tab orders;

Basic Operations

b;

Initialize database metadata. This command scans the PGDATA directory and builds the data dictionary for all databases, schemas, and tables.

exit;/\q;

Exit the PDU tool and return to the shell.

t;

Display all data types supported by PDU for data recovery.

Database Context

use <database>;

Switch to the specified database context. After switching, you can view and operate tables in that database.

set <schema>;

Switch to the specified schema within the current database.

Metadata Display

\l;

List all databases that have been initialized in PDU.

\dn;

List all schemas in the current database with table counts.

\dt;

List all tables in the current schema with their sizes.

\d+ <table>;

Show detailed table structure including column names, types, and modifiers.

\d <table>;

Show basic column types of the specified table.

Data Export

unload tab <table>;/u tab <table>;

Export a single table to CSV format. The output file will be saved in the database/schema directory.

unload sch <schema>;/u sch <schema>;

Export all tables in a schema to CSV. Also generates DDL and COPY SQL files.

unload ddl;/u ddl;

Generate DDL (CREATE TABLE) statements for the current schema.

unload copy;/u copy;

Generate COPY statements for importing the exported CSV files into PostgreSQL.

Accidental Operation Recovery

scan <table>;

Scan WAL archives to find deleted/updated records for a specific table. Shows time range, LSN coordinates, and recoverable record count.

scan manual;

Initialize metadata from manual configuration for cases where the database is completely corrupted.

restore del all;

Restore all deleted records found in the scan phase within the time range.

restore del <TxID>;

Restore deleted records from a specific transaction ID. Use after setting resmode to 'tx'.

restore upd all;

Restore all pre-update records (original data before UPDATE operations).

restore upd <TxID>;

Restore pre-update records from a specific transaction ID.

add <filenode> <table> <columns>;

Manually register a data file for recovery. The data file must be placed in restore/datafile directory.

restore db <db> <path>;

Initialize a customized database directory for recovery when the original PGDATA is damaged.

Dropped Table Recovery

scan drop;

Scan WAL archives to find dropped/truncated tables. Retrieves table structure from archived WAL files.

meta tab <table>;

Add a single table's structure to restore/tab.config for disk fragment scanning.

meta sch <schema>;

Add all tables in a schema to restore/tab.config for batch disk fragment scanning.

dropscan;/ds;

Perform disk fragment scanning for tables configured in restore/tab.config. Includes both datafile and TOAST scanning.

dropscan idx;/ds idx;

Build disk index before fragment scanning. Excludes existing data files to improve scanning efficiency.

dropscan repair;/ds repair;

Recover TOAST data from previously scanned TOAST fragments. Required when datafile scan shows failed records.

dropscan iso;/ds iso;

Perform disk scanning using saved image files instead of live disk. Use after enabling isomode.

dropscan copy;/ds copy;

Generate COPY statements for all recovered table files under restore/dropscan.

dropscan clean;/ds clean;

Delete all directories under restore/dropscan to clean up previous scan results.

Parameter Management

show;

Display all current parameter settings including WAL range, time range, recovery mode, and dropscan settings.

param <name> <value>;/p <name> <value>;

Set a specific parameter value. See Parameter Reference for all available parameters.

reset <parameter>;

Reset a specific parameter to its default value.

reset all;

Reset all parameters to their default values.