Recovery Configuration
configuration
of recovery
of a standby server
This chapter describes the settings available in the
recovery.conf> file. They apply only for the duration of the
recovery. They must be reset for any subsequent recovery you wish to
perform. They cannot be changed once recovery has begun.
Settings in recovery.conf> are specified in the format
name = 'value'>. One parameter is specified per line.
Hash marks (#) designate the rest of the
line as a comment. To embed a single quote in a parameter
value, write two quotes (''>).
A sample file, share/recovery.conf.sample>,
is provided in the installation's share/> directory.
Archive recovery settings
restore_command (string)
The shell command to execute to retrieve an archived segment of
the WAL file series. This parameter is required for archive recovery,
but optional for streaming replication.
Any %f> in the string is
replaced by the name of the file to retrieve from the archive,
and any %p> is replaced by the copy destination path name
on the server.
(The path name is relative to the current working directory,
i.e., the cluster's data directory.)
Any %r> is replaced by the name of the file containing the
last valid restart point. That is the earliest file that must be kept
to allow a restore to be restartable, so this information can be used
to truncate the archive to just the minimum required to support
restarting from the current restore. %r> is typically only
used by warm-standby configurations
(see ).
Write %%> to embed an actual %> character.
It is important for the command to return a zero exit status
only if it succeeds. The command will> be asked for file
names that are not present in the archive; it must return nonzero
when so asked. Examples:
restore_command = 'cp /mnt/server/archivedir/%f "%p"'
restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
restartpoint_command (string)
This parameter specifies a shell command that will be executed at
every restartpoint. This parameter is optional. The purpose of the
restartpoint_command> is to provide a mechanism for cleaning
up old archived WAL files that are no longer needed by the standby
server.
Any %r> is replaced by the name of the file
containing the last valid restart point. That is the earliest file that
must be kept to allow a restore to be restartable, so this information
can be used to truncate the archive to just the minimum required to
support restart from the current restore. %r> would
typically be used in a warm-standby configuration
(see ).
Write %%> to embed an actual %> character
in the command.
If the command returns a non-zero exit status then a WARNING log
message will be written.
recovery_end_command (string)
This parameter specifies a shell command that will be executed once only
at the end of recovery. This parameter is optional. The purpose of the
recovery_end_command> is to provide a mechanism for cleanup
following replication or recovery.
Any %r> is replaced by the name of the file containing the
last valid restart point, like in .
If the command returns a non-zero exit status then a WARNING log
message will be written and the database will proceed to start up
anyway. An exception is that if the command was terminated by a
signal, the database will not proceed with startup.
Recovery target settings
recovery_target_time
(timestamp)
This parameter specifies the time stamp up to which recovery
will proceed.
At most one of recovery_target_time> and
can be specified.
The default is to recover to the end of the WAL log.
The precise stopping point is also influenced by
.
recovery_target_xid (string)
This parameter specifies the transaction ID up to which recovery
will proceed. Keep in mind
that while transaction IDs are assigned sequentially at transaction
start, transactions can complete in a different numeric order.
The transactions that will be recovered are those that committed
before (and optionally including) the specified one.
At most one of recovery_target_xid> and
can be specified.
The default is to recover to the end of the WAL log.
The precise stopping point is also influenced by
.
recovery_target_inclusive
(boolean)
Specifies whether we stop just after the specified recovery target
(true), or just before the recovery target
(false).
Applies to both
and , whichever one is
specified for this recovery. This indicates whether transactions
having exactly the target commit time or ID, respectively, will
be included in the recovery. Default is true>.
recovery_target_timeline
(string)
Specifies recovering into a particular timeline. The default is
to recover along the same timeline that was current when the
base backup was taken. You only need to set this parameter
in complex re-recovery situations, where you need to return to
a state that itself was reached after a point-in-time recovery.
See for discussion.
Standby server settings
standby_mode (boolean)
Specifies whether to start the PostgreSQL> server as
a standby. If this parameter is on>, the server will
not stop recovery when the end of archived WAL is reached, but
will keep trying to continue recovery by fetching new WAL segments
using restore_command>
and/or by connecting to the primary server as specified by the
primary_conninfo> setting.
primary_conninfo (string)
Specifies a connection string to be used for the standby server
to connect with the primary. This string is in the format
accepted by the libpq PQconnectdb function,
described in . If any option is
unspecified in this string, then the corresponding environment
variable (see ) is checked. If the
environment variable is not set either, then
defaults are used.
The connection string should specify the host name (or address)
of the primary server, as well as the port number if it is not
the same as the standby server's default.
Also specify a user name corresponding to a role that has the
SUPERUSER> and LOGIN> privileges on the
primary (see
).
A password needs to be provided too, if the primary demands password
authentication. (The password can be provided either in
the primary_conninfo string or in a separate
~/.pgpass> file on the standby server.)
Do not specify a database name in the
primary_conninfo string.
This setting has no effect if standby_mode> is off>.
trigger_file (string)
Specifies a trigger file whose presence ends recovery in the
standby. If no trigger file is specified, the standby never exits
recovery.
This setting has no effect if standby_mode> is off>.