Skip to content

archive_cleanup_command

archive_cleanup_command sets the shell command that will be executed at every restart point. It is a sighup setting present in PG12–18; the latest recorded boot default is empty.
Note

Fact — official short description: “Sets the shell command that will be executed at every restart point.”

Identity

Type , Valuestring
Upstream pg_settings type
Context , Valuesighup
Takes effect after configuration reload
Unit , Value—
Raw unit
Range , Value—
Raw limits in the last observed version
Enum values , Value—
— for non-enum types
Category , ValueWrite-Ahead Log / Archive Recovery
Upstream classification
Latest boot value , Value""
empty string

Lifecycle

Fact Value
First observed PG12
Present in PG12–19 Beta 3
Removed in No
Introduction commit 2dedf4d9a899 — Integrate recovery.conf into postgresql.conf
Commit date 2018-11-25
Discussion thread 1

Default history

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG12–19 Beta 3 "" — empty string

How it works

Sets the shell command that will be executed at every restart point. A configuration reload applies a new value; existing work already in flight is not retroactively changed.

At every restartpoint during archive recovery, PostgreSQL expands %r to the oldest WAL file still needed for a restartable recovery and runs this command. pg_archivecleanup is the usual implementation, but deleting from an archive shared by several standbys can strand another consumer.

Monitor and change archive_cleanup_command together with archive_mode, archive_command, archive_library. Validate on the relevant server role and real workload, then use its sighup context to choose session change, reload, or restart; a historical boot default is not the current effective value.

Tuning advice

Tip

Advice. These are workload-specific starting points and must be validated with measurements.

Workload Guidance
OLTP Manage archive_cleanup_command as part of the backup/restore protocol: the command or module must be idempotent, fail visibly, and be verified by restoring from the real archive—not merely by exit status.
OLAP Provision archive throughput and capacity for bulk-load WAL peaks. If archiving falls behind, throttle the job and alert; never hide backlog with false success or aggressive cleanup.
Small nodes Enable it only for a defined PITR requirement and use a mature backup tool. Keep rebuildable instances simple, but never install a no-op command that creates the illusion of a backup.

Pigsty

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

Template Effective value Versus upstream boot Source expression
OLTP Unmodified — —
OLAP Unmodified — —
CRIT Unmodified — —
TINY Unmodified — —
Caution

Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG12–19 Beta 3 unmodified; OLAP: PG12–19 Beta 3 unmodified; CRIT: PG12–19 Beta 3 unmodified; TINY: PG12–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

Common pitfalls

  • Running destructive cleanup against an archive shared by other standbys or restore jobs.
  • Misreading %r as the last replayed file; it is the earliest file needed to keep recovery restartable.
  • Using a command that is not idempotent when a restartpoint repeats or an archive file is already absent.
  • Assuming a reload executes the command immediately; it runs at recovery restartpoints.
  • Letting shell quoting or an unexpected archive path turn cleanup into deletion outside the intended archive.

archive_mode · archive_command · archive_library · archive_timeout · restore_command · recovery_end_command

References