archive_command
Fact — official short description: “Sets the shell command that will be called to archive a WAL file.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.0–19 Beta 3 | "" |
— | empty string |
How it works
Sets the shell command that will be called to archive a WAL file. A configuration reload applies a new value; existing work already in flight is not retroactively changed.
The archiver expands %p to the source path and %f to the WAL file name, and considers exit status zero a durable success. A nonzero result is retried; a false success allows PostgreSQL to recycle the only local copy and silently breaks the archive chain.
Monitor and change archive_command together with archive_mode, archive_library, archive_timeout. 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
Advice. These are workload-specific starting points and must be validated with measurements.
| Workload | Guidance |
|---|---|
| OLTP | Manage archive_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 | pgbackrest --stanza=fixture archive-push %p |
different | 'pgbackrest --stanza={{ pg_cluster }} archive-push %p' |
| OLAP | pgbackrest --stanza=fixture archive-push %p |
different | 'pgbackrest --stanza={{ pg_cluster }} archive-push %p' |
| CRIT | pgbackrest --stanza=fixture archive-push %p |
different | 'pgbackrest --stanza={{ pg_cluster }} archive-push %p' |
| TINY | pgbackrest --stanza=fixture archive-push %p |
different | 'pgbackrest --stanza={{ pg_cluster }} archive-push %p' |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = pgbackrest –stanza=fixture archive-push %p (dcs); OLAP: PG9.0–19 Beta 3 = pgbackrest –stanza=fixture archive-push %p (dcs); CRIT: PG9.0–19 Beta 3 = pgbackrest –stanza=fixture archive-push %p (dcs); TINY: PG9.0–19 Beta 3 = pgbackrest –stanza=fixture archive-push %p (dcs). Advice, pending human review — Editorial interpretation, pending human maintainer review: the override appears intended to bind archiving to the pgBackRest stanza used by Pigsty for PITR; confirm it against the current Pigsty templates, hardware fixture, and operational guarantees before publication.
Common pitfalls
- Returning success before the archive copy is durable or verified.
- Failing to quote %p/%f safely in a shell command.
- Letting repeated failures fill pg_wal and stop the server.
- Confusing pg_settings base units with human-readable configuration units.
- Benchmarking throughput without a crash-recovery and archive-restore test.
Related parameters
archive_mode · archive_library · archive_timeout · archive_cleanup_command · restore_command · recovery_end_command