xlogdump

Name

xlogdump  --  reads transaction log segments and outputs the operations within the file

Synopsis

xlogdump [option] [segment file]

Description

xlogdump is a utility for reading a PostgreSQL transaction log segment or. set of segments. It can scan segment files without connection to a backend to simply return the raw data contained in the files or it can be used with the backend that created the segments to translate the oids and output the names of the database objects.

Options

The following command-line options control the content and format of the output.

segments

Specifies the name of the transaction log segment to be dumped. You can specifie more than one file, in wich case all of them will be scanned in the given order.

-r operation
--rmname operation

Outuputs only the transaction log records containing the specified operation. The operations can be: XLOG, XACT, SMGR, CLOG, DBASE, TBSPC, MXACT, HEAP, BTREE, HASH, RTREE, GIST, SEQ.

-t
--transactions

Outuputs only transaction info: the xid, total length and status of each transaction. The status can be COMMITED, ABORTED or NOT COMMITED for implicit aborts.

-s
--statements

Tries to build fake statements that produce the physical changes found within the xlog segments. This works well for INSERT commands, for UPDATE and DELETE statements there's no way to rebuild the WHERE clause. To use this option you must have a connection to the database. (I know that requiring a connection to the database in this kind of program may seem silly, but this is still an alpha version. In the next version I'll use only the database files.)

The following command-line options control the database connection parameters.

-h host
--host=host

Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted.

-p port
--port=port

Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default.

-U username

Connect as the given user, it must have access to all the databases in the cluster.

Environment

PGDATABASE
PGHOST
PGPORT
PGUSER

Default connection parameters.

Examples

To dump the contents of all segments in pg_xlog without a running backend:

$ xlogdump $PGDATA/pg_xlog/*

To get the status of all transaction in a database cluster:

$ xlogdump -t $PGDATA/pg_xlog/*

To dump the transaction logs using the object names: file:

$ xlogdump -h localhost $PGDATA/pg_xlog/*

See Also