{"Entry":{"collection":"guc","key":"archive_command","name":"archive_command","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Write-Ahead Log / Archiving","category_zh":"","changed_in":["15","18"],"changes":[{"documentation_changed":false,"fields":{},"from":"7.4","status":"added","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.0","status":"changed","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.3","status":"changed","to":"9.4"},{"documentation_changed":true,"fields":{},"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":{"extra_desc":{"from":null,"to":"This is used only if \"archive_library\" is not set."}},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{},"from":"15","status":"changed","to":"16"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"This is used only if \"archive_library\" is not set.","to":"An empty string means use \"archive_library\"."}},"from":"17","status":"changed","to":"18"}],"content_hash":"d66be3669eb87684b6ec6712ef2b5ff8b4a3ae162f5772b963843093e5a04c0a","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"Empty string"}],"editorial":{"advice":{"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.","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.","small":"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."},"mechanism":["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."],"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."],"references":[{"title":"PostgreSQL 19 Beta 4: archive_command","url":"https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-ARCHIVE-COMMAND"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["archive_mode","archive_library","archive_timeout","archive_cleanup_command","restore_command","recovery_end_command"],"summary":"archive_command — Sets the shell command that will be called to archive a WAL file. Observed in PG9.0–19 Beta 4; its last measured boot default is empty string in PG19 Beta 4, with sighup context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"8.0","group":"Write-Ahead Log","group_slug":"wal","imported_at":"2026-09-27T17:57:30.75336+08:00","intro_commit":{},"key":"archive_command","last_version":"20","max_val":"","min_val":"","name":"archive_command","position":9,"present_in":["8.0","8.1","8.2","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":"The local shell command to execute to archive a completed WAL file segment.","short_desc_zh":"","source_rev":"english-manuals:6f8041df52107b90e28760d91a04b9b98ab12bab5d2b6dbd6c2e35b6e70d919a","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"archive_command","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"archive_command","SourceRevision":"english-manuals:6f8041df52107b90e28760d91a04b9b98ab12bab5d2b6dbd6c2e35b6e70d919a","Facts":{"boot_val":"","category":"Write-Ahead Log / Archiving","context":"sighup","description":"The local shell command to execute to archive a completed WAL file segment. Any %p in the string is replaced by the path name of the file to archive, and any %f is replaced by only the file name. (The path name is relative to the working directory of the server, i.e., the cluster's data directory.) Use %% to embed an actual % character in the command. It is important for the command to return a zero exit status only if it succeeds. For more information see Section 25.3.1. This parameter can only be set in the postgresql.conf file or on the server command line. It is only used if archive_mode was enabled at server start and archive_library is set to an empty string. If both archive_command and archive_library are set, an error will be raised. If archive_command is an empty string (the default) while archive_mode is enabled (and archive_library is set to an empty string), WAL archiving is temporarily disabled, but the server continues to accumulate WAL segment files in the expectation that a command will soon be provided. Setting archive_command to a command that does nothing but return true, e.g., /bin/true (REM on Windows), effectively disables archiving, but also breaks the chain of WAL files needed for archive recovery, so it should only be used in unusual circumstances.","doc":{"anchor":"GUC-ARCHIVE-COMMAND","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"An empty string means use \"archive_library\".","lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"archive_command","short_desc":"Sets the shell command that will be called to archive a WAL file.","source":"pg-settings-source-snapshot","unit":null,"vartype":"string"},"ManualEvidence":{"doc":{"anchor":"GUC-ARCHIVE-COMMAND","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"archive_command","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"archive_command","Summary":"","BodyHTML":"\u003cp\u003e本地 shell 命令被执行来归档一个完成的 WAL 段文件。字符串中的任何\u003ccode\u003e%p\u003c/code\u003e被替换成要被归档的文件的路径名，而\u003ccode\u003e%f\u003c/code\u003e只被文件名替换（路径名是相对于服务器的工作目录，即集簇的数据目录）。如果要在命令里嵌入一个真正的\u003ccode\u003e%\u003c/code\u003e字符，可以使用\u003ccode\u003e%%\u003c/code\u003e。有一点很重要，该命令只在成功时返回一个零作为退出状态。更多信息请见\u003ca href=\"/docs/18/continuous-archiving.html#BACKUP-ARCHIVING-WAL\" rel=\"nofollow\"\u003e第 25.3.1 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e这个参数只能在\u003ccode\u003epostgresql.conf\u003c/code\u003e文件或服务器命令行中设置。除非在服务器启动时启用了\u003ccode\u003earchive_mode\u003c/code\u003e并且\u003ccode\u003earchive_library\u003c/code\u003e设置为空字符串，否则将被忽略。如果\u003ccode\u003earchive_command\u003c/code\u003e和\u003ccode\u003earchive_library\u003c/code\u003e都被设置，则会报错。如果\u003ccode\u003earchive_command\u003c/code\u003e是空字符串（默认值），而\u003ccode\u003earchive_mode\u003c/code\u003e已启用（并且\u003ccode\u003earchive_library\u003c/code\u003e设置为空字符串），WAL归档将暂时被禁用，但服务器将继续积累WAL段文件，期望很快会提供命令。将\u003ccode\u003earchive_command\u003c/code\u003e设置为一个什么都不做但返回true的命令，例如\u003ccode\u003e/bin/true\u003c/code\u003e（Windows上为\u003ccode\u003eREM\u003c/code\u003e），实际上禁用了归档，但也破坏了用于归档恢复所需的WAL文件链，因此只应在不寻常的情况下使用。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"bd4eaf31498b16cd2a81009593de4f641987879f475699b6cac96c63c9f94b0a","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e本地 shell 命令被执行来归档一个完成的 WAL 段文件。字符串中的任何\u003ccode class=\"literal\"\u003e%p\u003c/code\u003e被替换成要被归档的文件的路径名，而\u003ccode class=\"literal\"\u003e%f\u003c/code\u003e只被文件名替换（路径名是相对于服务器的工作目录，即集簇的数据目录）。如果要在命令里嵌入一个真正的\u003ccode class=\"literal\"\u003e%\u003c/code\u003e字符，可以使用\u003ccode class=\"literal\"\u003e%%\u003c/code\u003e。有一点很重要，该命令只在成功时返回一个零作为退出状态。更多信息请见\u003ca href=\"/docs/18/continuous-archiving.html#BACKUP-ARCHIVING-WAL\" title=\"25.3.1. 设置 WAL 归档\"\u003e第 25.3.1 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e这个参数只能在\u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e文件或服务器命令行中设置。除非在服务器启动时启用了\u003ccode class=\"varname\"\u003earchive_mode\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\"\u003earchive_command\u003c/code\u003e是空字符串（默认值），而\u003ccode class=\"varname\"\u003earchive_mode\u003c/code\u003e已启用（并且\u003ccode class=\"varname\"\u003earchive_library\u003c/code\u003e设置为空字符串），WAL归档将暂时被禁用，但服务器将继续积累WAL段文件，期望很快会提供命令。将\u003ccode class=\"varname\"\u003earchive_command\u003c/code\u003e设置为一个什么都不做但返回true的命令，例如\u003ccode class=\"literal\"\u003e/bin/true\u003c/code\u003e（Windows上为\u003ccode class=\"literal\"\u003eREM\u003c/code\u003e），实际上禁用了归档，但也破坏了用于归档恢复所需的WAL文件链，因此只应在不寻常的情况下使用。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.0","8.1","8.2","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}
