Parameter · Write-Ahead Log / Archiving
archive_mode
Allows archiving of WAL files using "archive_command".
- Default:
off - Type: enum
- Values: always · on · off
- Applies: Restart required
In plain words
WAL archiving copies every completed WAL segment somewhere safe, so you can restore a backup and replay to any point in time (PITR). archive_mode switches the archiver process on. You then tell it how to copy files with archive_command or archive_library.
Changing it needs a restart, so many sites enable it at install time and only set the command later.
For DBAs and operators
- off: no archiver. Segments are recycled after checkpoints.
- on: the primary archives. A standby does not archive (after promotion it starts archiving its own WAL).
- always: a standby also archives every segment it receives or restores, useful for a separate archive per site; the archive must cope with the same file arriving twice with identical content.
Requires wal_level replica or higher. With archiving on, a completed segment gets a pg_wal/archive_status/<segment>.ready file; it is not removed until the archiver marks it .done. A broken command therefore makes pg_wal grow without limit.
If neither command nor library is set: WARNING: "archive_mode" enabled, yet archiving is not configured and WAL accumulates.
SELECT archived_count, last_archived_wal, failed_count, last_failed_wal, last_failed_time FROM pg_stat_archiver;How to change it
Change in postgresql.conf or ALTER SYSTEM, then restart the server.
See it in context
Related parameters
archive_command archive_library archive_timeout wal_level restore_command