> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/appendixes/contrib/basic-archive.md).

# F.5. basic\_archive — WAL 封存模組範例 \#

[F.5.1. 設定參數](#BASIC-ARCHIVE-CONFIGURATION-PARAMETERS)

[F.5.2. 注意事項](#BASIC-ARCHIVE-NOTES)

[F.5.3. 作者](#BASIC-ARCHIVE-AUTHOR)

`basic_archive` 是封存模組的範例。此模組會將已完成的 WAL 區段檔案複製到指定目錄。它或許沒有特別實用，但可作為開發自訂封存模組的起點。關於封存模組的更多資訊，請參閱[第 49 章](/server-programming/archive-modules.md)。

此模組必須透過 [archive\_library](/server-administration/runtime-config/runtime-config-wal.md#GUC-ARCHIVE-LIBRARY) 載入，且必須啟用 [archive\_mode](/server-administration/runtime-config/runtime-config-wal.md#GUC-ARCHIVE-MODE)，才能運作。

## F.5.1. 設定參數 [#](#BASIC-ARCHIVE-CONFIGURATION-PARAMETERS)

`basic_archive.archive_directory` (`string`): 伺服器應複製 WAL 區段檔案的目錄。此目錄必須已存在。預設值是空字串，實際上會停止 WAL 封存；但若啟用 [archive\_mode](/server-administration/runtime-config/runtime-config-wal.md#GUC-ARCHIVE-MODE)，伺服器會累積 WAL 區段檔案，預期很快就會提供設定值。

這些參數必須在 `postgresql.conf` 中設定。典型的使用方式如下：

```

# postgresql.conf
archive_mode = 'on'
archive_library = 'basic_archive'
basic_archive.archive_directory = '/path/to/archive/directory'
```

## F.5.2. 注意事項 [#](#BASIC-ARCHIVE-NOTES)

伺服器當機可能會在封存目錄中留下以 `archtemp` 為前綴的暫存檔。建議在當機後重新啟動伺服器之前刪除這類檔案。伺服器運作期間，只要這些檔案與任何仍在進行的封存無關，便可安全移除；但使用者進行此操作時應格外小心。

## F.5.3. 作者 [#](#BASIC-ARCHIVE-AUTHOR)

Nathan Bossart

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/basic-archive.html)（原文版本：18.6；核對日期：2026-09-06）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/appendixes/contrib/basic-archive.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
