PostgreSQL Backup & Recovery
Learn how PostgreSQL archive_command works, what makes it reliable, and how to avoid hidden failure modes that break recovery.
Configuration parameter that specifies the shell command to execute to archive a completed WAL segment.
archive_command is the shell command PostgreSQL executes when a WAL segment is ready to be archived.
It receives placeholders for source path and WAL filename and must return success only when durable copy is complete.
A weak command script creates invisible recovery risk even if backups look healthy.
Commands that suppress errors, write to unstable destinations, or skip integrity checks can break your WAL chain.
Treat archive_command as a critical production pipeline, not a one-time setup.
archive_command writes WAL out; restore_command reads it back during recovery.
Both ends must be tested together in drills to validate actual PITR readiness.