PostgreSQL Backup & Recovery

archive_mode

Understand archive_mode values in PostgreSQL and how they affect WAL archiving behavior on primaries and standbys.

Definition

Configuration parameter to enable WAL archiving. Values: off | on | always (for standbys).

What archive_mode Controls

archive_mode enables WAL archiving behavior in PostgreSQL and works together with archive_command.

Common values are off, on, and always. The right setting depends on topology and how you handle failover and standby behavior.

on vs always

  • on: archive completed WAL on the primary
  • always: archive on standbys too, useful in specific HA/failover designs
  • off: disables WAL archiving and limits recovery precision

Design Considerations

Most production setups start with archive_mode=on on the primary. More advanced topologies may use always with careful deduplication and operational policy.

Choose settings based on failover strategy, operational ownership, and retention consistency requirements.

Validation and Safety

  • Confirm archive output continuity during failover drills
  • Verify no duplicate/overwritten WAL artifacts in shared targets
  • Test recovery from newest base backup to selected recovery target

Frequently Asked Questions

What happens if archive_mode is off?
WAL archiving is disabled, which prevents full PITR beyond local WAL retention.
Should every production cluster enable archive_mode?
If you need reliable PITR or strong DR posture, yes.
When is archive_mode=always useful?
In specific HA designs where standby archiving is required and carefully governed.
Is archive_mode enough by itself?
No. You also need a robust archive_command, retention policy, and restore drills.
How do teams verify archive_mode behavior?
Observe archived WAL continuity in normal operation and during controlled failover tests.