pg_receivexlogpg_receivexlog1Applicationpg_receivexlogstream transaction logs from a PostgreSQL serverpg_receivexlogoption>
Description
pg_receivexlog is used to stream transaction log
from a running PostgreSQL cluster. The transaction
log is streamed using the streaming replication protocol, and is written
to a local directory of files. This directory can be used as the archive
location for doing a restore using point-in-time recovery (see
).
pg_receivexlog streams the transaction
log in real time as it's being generated on the server, and does not wait
for segments to complete like does.
For this reason, it is not necessary to set
when using
pg_receivexlog.
The transaction log is streamed over a regular
PostgreSQL connection, and uses the replication
protocol. The connection must be made with a superuser or a user
having REPLICATION permissions (see
), and pg_hba.conf
must explicitly permit the replication connection. The server must also be
configured with set high enough to
leave at least one session available for the stream.
If the connection is lost, or if it cannot be initially established,
with a non-fatal error, pg_receivexlog will
retry the connection indefinitely, and reestablish streaming as soon
as possible. To avoid this behavior, use the -n
parameter.
Options
Directory to write the output to.
This parameter is required.
Don't loop on connection errors. Instead, exit right away with
an error.
Specifies the number of seconds between status packets sent back to the
server. This allows for easier monitoring of the progress from server.
A value of zero disables the periodic status updates completely,
although an update will still be sent when requested by the server, to
avoid timeout disconnect. The default value is 10 seconds.
Require pg_receivexlog to use an existing
replication slot (see ).
When this option is used, pg_receivexlog> will report
a flush position to the server, indicating when each segment has been
synchronized to disk so that the server can remove that segment if it
is not otherwise needed. When using this parameter, it is important
to make sure that pg_receivexlog> cannot become the
synchronous standby through an incautious setting of
; it does not flush
data frequently enough for this to work correctly.
Enables verbose mode.
The following command-line options control the database connection parameters.
Specifies parameters used to connect to the server, as a connection
string. See for more information.
The option is called --dbname> for consistency with other
client applications, but because pg_receivexlog
doesn't connect to any particular database in the cluster, database
name in the connection string will be ignored.
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.
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.
User name to connect as.
Never issue a password prompt. If the server requires
password authentication and a password is not available by
other means such as a .pgpass file, the
connection attempt will fail. This option can be useful in
batch jobs and scripts where no user is present to enter a
password.
Force pg_receivexlog to prompt for a
password before connecting to a database.
This option is never essential, since
pg_receivexlog will automatically prompt
for a password if the server demands password authentication.
However, pg_receivexlog will waste a
connection attempt finding out that the server wants a password.
In some cases it is worth typing
Other options are also available:
Print the pg_receivexlog version and exit.
Show help about pg_receivexlog command line
arguments, and exit.
Environment
This utility, like most other PostgreSQL> utilities,
uses the environment variables supported by libpq>
(see ).
Notes
When using pg_receivexlog instead of
as the main WAL backup method, it is
strongly recommended to use replication slots. Otherwise, the server is
free to recycle or remove transaction log files before they are backed up,
because it does not have any information, either
from or the replication slots, about
how far the WAL stream has been archived. Note, however, that a
replication slot will fill up the server's disk space if the receiver does
not keep up with fetching the WAL data.
Examples
To stream the transaction log from the server at
mydbserver and store it in the local directory
/usr/local/pgsql/archive:
$pg_receivexlog -h mydbserver -D /usr/local/pgsql/archiveSee Also