{"Entry":{"collection":"guc","key":"archive_mode","name":"archive_mode","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Write-Ahead Log / Archiving","category_zh":"","changed_in":["9.5","17"],"changes":[{"documentation_changed":false,"fields":{},"from":"8.2","status":"added","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.0","status":"changed","to":"9.1"},{"documentation_changed":true,"fields":{"enumvals":{"from":null,"to":["always","on","off"]},"vartype":{"from":"bool","to":"enum"}},"from":"9.4","status":"changed","to":"9.5"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{"short_desc":{"from":"Allows archiving of WAL files using archive_command.","to":"Allows archiving of WAL files using \"archive_command\"."}},"from":"16","status":"changed","to":"17"},{"documentation_changed":true,"fields":{},"from":"18","status":"changed","to":"19"}],"content_hash":"505a3940a96d7e4be1655b13c0f6a2737dbcaf7a0b9b9b8e09ffecee7f2373a9","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"off"}],"editorial":{"advice":{"olap":"Provision archive bandwidth and destination capacity for bulk-load WAL bursts. If the archive cannot keep up, throttling or scheduling the batch is safer than allowing pg_wal to fill.","oltp":"Enable it for a defined PITR or log-shipping requirement, pair it with a reliable idempotent archive implementation, and alert on pg_stat_archiver failures, archive age, and pg_wal growth. Test restores rather than treating successful command exits as sufficient evidence.","small":"Use a simple managed tool such as pgBackRest only when retention and restore procedures are understood. Keep the archive off for disposable databases rather than enabling it with a placeholder command."},"mechanism":["When enabled, PostgreSQL runs the WAL archiver and submits each completed segment to archive_command or, in versions that provide it, archive_library before that segment can be recycled. The mode is separate from the command or library, so the archive destination logic can be reloaded while archiving remains enabled.","The on and always modes behave the same during normal primary operation. In recovery or standby mode, on does not archive received WAL, while always also archives segments restored from an archive or received through streaming replication.","Enabling the mode does not prove that an archive is healthy or recoverable. A command that fails causes WAL to accumulate in pg_wal; a command that falsely reports success can create an unrecoverable archive chain. Point-in-time recovery also requires a suitable base backup and tested restore procedure."],"pitfalls":["Enabling archive_mode with an empty or failing command and letting pg_wal fill.","Using a command such as /bin/true, which reports success while breaking the recoverable WAL chain.","Assuming archive_mode is reloadable even though changing it requires a server restart.","Treating WAL archiving as a substitute for a base backup and restore test.","Using always with a shared archive without duplicate-safe, race-free handling."],"references":[{"title":"PostgreSQL 19 Beta 4: archive_mode","url":"https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-ARCHIVE-MODE"},{"title":"PostgreSQL 18: Continuous Archiving and PITR","url":"https://www.postgresql.org/docs/18/continuous-archiving.html"},{"title":"PostgreSQL 18: Continuous Archiving in Standby","url":"https://www.postgresql.org/docs/18/warm-standby.html#CONTINUOUS-ARCHIVING-IN-STANDBY"},{"title":"PostgreSQL 18: pg_stat_archiver","url":"https://www.postgresql.org/docs/18/monitoring-stats.html#MONITORING-PG-STAT-ARCHIVER-VIEW"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["archive_command","archive_library","archive_timeout","wal_level","restore_command","max_wal_size"],"summary":"archive_mode — Allows archiving of WAL files using \"archive_command\". Observed in PG9.0–19 Beta 4; its last measured boot default is off in PG19 Beta 4, with postmaster context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"8.3","group":"Write-Ahead Log","group_slug":"wal","imported_at":"2026-09-27T17:57:30.76136+08:00","intro_commit":{},"key":"archive_mode","last_version":"20","max_val":"","min_val":"","name":"archive_mode","position":11,"present_in":["8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"When archive_mode is enabled, completed WAL segments are sent to archive storage by setting archive_command or archive_library.","short_desc_zh":"","source_rev":"english-manuals:2b6516dbdce9de394fadf8507dcf4c3d6363082f75d7da142918786c47fbb8a6","unit":"","vartype":"enum"}},"Definition":{"Collection":"guc","Key":"archive_mode","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"archive_mode","SourceRevision":"english-manuals:2b6516dbdce9de394fadf8507dcf4c3d6363082f75d7da142918786c47fbb8a6","Facts":{"boot_val":"off","category":"Write-Ahead Log / Archiving","context":"postmaster","description":"When archive_mode is enabled, completed WAL segments are sent to archive storage by setting archive_command or archive_library. In addition to off, to disable, there are two modes: on, and always. During normal operation, there is no difference between the two modes, but when set to always the WAL archiver is enabled also during archive recovery or standby mode. In always mode, all files restored from the archive or streamed with streaming replication will be archived (again). See Section 26.2.9 for details. archive_mode is a separate setting from archive_command and archive_library so that archive_command and archive_library can be changed without leaving archiving mode. This parameter can only be set at server start. archive_mode cannot be enabled when wal_level is set to minimal.","doc":{"anchor":"GUC-ARCHIVE-MODE","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"},"documented":true,"enumvals":["always","on","off"],"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"archive_mode","short_desc":"Allows archiving of WAL files using \"archive_command\".","source":"pg-settings-source-snapshot","unit":null,"vartype":"enum"},"ManualEvidence":{"doc":{"anchor":"GUC-ARCHIVE-MODE","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"archive_mode","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"archive_mode","Summary":"","BodyHTML":"\u003cp\u003e当启用\u003ccode\u003earchive_mode\u003c/code\u003e时，完成的WAL段会通过设置\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\" rel=\"nofollow\"\u003earchive_command\u003c/a\u003e或\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\" rel=\"nofollow\"\u003earchive_library\u003c/a\u003e发送到归档存储。除了用于禁用归档的\u003ccode\u003eoff\u003c/code\u003e外，还有两种模式：\u003ccode\u003eon\u003c/code\u003e和 \u003ccode\u003ealways\u003c/code\u003e。在正常操作期间，这两种模式之间没有区别，但当设置为\u003ccode\u003ealways\u003c/code\u003e时，WAL归档程序在归档恢复或备库模式下也会被启用。在\u003ccode\u003ealways\u003c/code\u003e模式下，从归档中恢复的所有文件或通过流复制传输的文件将被再次归档。详细信息请参见\u003ca href=\"/docs/18/warm-standby.html#CONTINUOUS-ARCHIVING-IN-STANDBY\" rel=\"nofollow\"\u003e第 26.2.9 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e\u003ccode\u003earchive_mode\u003c/code\u003e是一个独立的设置，不同于 \u003ccode\u003earchive_command\u003c/code\u003e和 \u003ccode\u003earchive_library\u003c/code\u003e，这样 \u003ccode\u003earchive_command\u003c/code\u003e和 \u003ccode\u003earchive_library\u003c/code\u003e可以在不离开归档模式的情况下进行更改。此参数只能在服务器启动时设置。当\u003ccode\u003ewal_level\u003c/code\u003e设置为\u003ccode\u003eminimal\u003c/code\u003e时，无法启用\u003ccode\u003earchive_mode\u003c/code\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"2c242d7605c79533cc23426ada6f62f84bcbd36230273554707606886cd07b64","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e当启用\u003ccode class=\"varname\"\u003earchive_mode\u003c/code\u003e时，完成的WAL段会通过设置\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-COMMAND\"\u003earchive_command\u003c/a\u003e或\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-ARCHIVE-LIBRARY\"\u003earchive_library\u003c/a\u003e发送到归档存储。除了用于禁用归档的\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e外，还有两种模式：\u003ccode class=\"literal\"\u003eon\u003c/code\u003e和 \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e。在正常操作期间，这两种模式之间没有区别，但当设置为\u003ccode class=\"literal\"\u003ealways\u003c/code\u003e时，WAL归档程序在归档恢复或备库模式下也会被启用。在\u003ccode class=\"literal\"\u003ealways\u003c/code\u003e模式下，从归档中恢复的所有文件或通过流复制传输的文件将被再次归档。详细信息请参见\u003ca href=\"/docs/18/warm-standby.html#CONTINUOUS-ARCHIVING-IN-STANDBY\" title=\"26.2.9. 在备库中持续归档\"\u003e第 26.2.9 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e\u003ccode class=\"varname\"\u003earchive_mode\u003c/code\u003e是一个独立的设置，不同于 \u003ccode class=\"varname\"\u003earchive_command\u003c/code\u003e和 \u003ccode class=\"varname\"\u003earchive_library\u003c/code\u003e，这样 \u003ccode class=\"varname\"\u003earchive_command\u003c/code\u003e和 \u003ccode class=\"varname\"\u003earchive_library\u003c/code\u003e可以在不离开归档模式的情况下进行更改。此参数只能在服务器启动时设置。当\u003ccode class=\"varname\"\u003ewal_level\u003c/code\u003e设置为\u003ccode class=\"literal\"\u003eminimal\u003c/code\u003e时，无法启用\u003ccode class=\"varname\"\u003earchive_mode\u003c/code\u003e。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
