postgresql_16:4.5.5.6 Recovery Target
PostgreSQL 16 > Server Administration > Server Configuration > Write Ahead Log > Recovery Target
By default, recovery will recover to the end of the WAL log. The following parameters can be used to specify an earlier stopping point. At most one of recovery_target, recovery_target_lsn, recovery_target_name, recovery_target_time, or recovery_target_xid can be used; if more than one of these is specified in the configuration file, an error will be raised. These parameters can only be set at server start.
recovery_target = 'immediate'
This parameter specifies that recovery should end as soon as a consistent state is reached, i.e., as early as possible. When restoring from an online backup, this means the point where taking the backup ended.
Technically, this is a string parameter, but 'immediate' is currently the only allowed value.
recovery_target_name (string)
This parameter specifies the named restore point (created with pg_create_restore_point()) to which recovery will proceed.
recovery_target_time (timestamp)
This parameter specifies the time stamp up to which recovery will proceed. The precise stopping point is also influenced by (see guc-recovery-target-inclusive).
The value of this parameter is a time stamp in the same format accepted by the timestamp with time zone data type, except that you cannot use a time zone abbreviation (unless the (see guc-timezone-abbreviations) variable has been set earlier in the configuration file). Preferred style is to use a numeric offset from UTC, or you can write a full time zone name, e.g., Europe/Helsinki not EEST.
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. The precise stopping point is also influenced by (see guc-recovery-target-inclusive).
recovery_target_lsn (pg_lsn)
This parameter specifies the LSN of the write-ahead log location up to which recovery will proceed. The precise stopping point is also influenced by (see guc-recovery-target-inclusive). This parameter is parsed using the system data type pg_lsn (see postgresql_16:3.5.20).
The following options further specify the recovery target, and affect what happens when the target is reached:
recovery_target_inclusive (boolean)
Specifies whether to stop just after the specified recovery target (on), or just before the recovery target (off). Applies when (see guc-recovery-target-lsn), (see guc-recovery-target-time), or (see guc-recovery-target-xid) is specified. This setting controls whether transactions having exactly the target WAL location (LSN), commit time, or transaction ID, respectively, will be included in the recovery. Default is on.
recovery_target_timeline (string)
Specifies recovering into a particular timeline. The value can be a numeric timeline ID or a special value. The value current recovers along the same timeline that was current when the base backup was taken. The value latest recovers to the latest timeline found in the archive, which is useful in a standby server. latest is the default.
To specify a timeline ID in hexadecimal (for example, if extracted from a WAL file name or history file), prefix it with a 0x. For instance, if the WAL file name is 00000011000000A10000004F, then the timeline ID is 0x11 (or 17 decimal).
You usually 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 (see postgresql_16:4.11.3.5) for discussion.
recovery_target_action (enum)
Specifies what action the server should take once the recovery target is reached. The default is pause, which means recovery will be paused. promote means the recovery process will finish and the server will start to accept connections. Finally shutdown will stop the server after reaching the recovery target.
The intended use of the pause setting is to allow queries to be executed against the database to check if this recovery target is the most desirable point for recovery. The paused state can be resumed by using pg_wal_replay_resume() (see (see functions-recovery-control-table)), which then causes recovery to end. If this recovery target is not the desired stopping point, then shut down the server, change the recovery target settings to a later target and restart to continue recovery.
The shutdown setting is useful to have the instance ready at the exact replay point desired. The instance will still be able to replay more WAL records (and in fact will have to replay WAL records since the last checkpoint next time it is started).
Note that because recovery.signal will not be removed when recovery_target_action is set to shutdown, any subsequent start will end with immediate shutdown unless the configuration is changed or the recovery.signal file is removed manually.
This setting has no effect if no recovery target is set. If (see guc-hot-standby) is not enabled, a setting of pause will act the same as shutdown. If the recovery target is reached while a promotion is ongoing, a setting of pause will act the same as promote.
In any case, if a recovery target is configured but the archive recovery ends before the target is reached, the server will shut down with a fatal error.