Configuration parameter

recovery_end_command — PostgreSQL configuration parameter

Category Write Ahead Log

This parameter specifies a shell command that will be executed once only at the end of recovery.

At a glance

Property Value
Parameter recovery_end_command
Category Write Ahead Log
Default (see documentation)
Value type string
Change scope Per-session (SET)
Available in PostgreSQL 12, 13, 14, 15, 16, 17, 18, 19 (added in 12)

What it does

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 restartpoint, like in archive_cleanup_command.

If the command returns a nonzero 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 or an error by the shell (such as command not found), the database will not proceed with startup.

(Description quoted from the official PostgreSQL documentation.)

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

Inspect the current value and source with SHOW recovery_end_command; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'recovery_end_command';.

Tuning guidance

This is a point-in-time-recovery control, used only while restoring a backup, not during normal operation. Set it in the recovery configuration to define the exact stopping point or restore action you want, perform the recovery, then remove it. It has no effect on a normally running primary.

Reference

PostgreSQL documentation — recovery_end_command.

Keep going

Related & next steps

Concepts on this page

Was this helpful?

← All configuration parameters