> 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/15/appendixes/additional-supplied-modules/basebackup_to_shell.md).

# F.5. basebackup\_to\_shell

## F.5. basebackup\_to\_shell

[F.5.1. Configuration Parameters](#id-1.11.7.14.5)

[F.5.2. Author](#id-1.11.7.14.6)

`basebackup_to_shell` 新增名為 `shell` 的自訂基礎備份目標。這使得你可以執行 `pg_basebackup --target=shell`；或者依本模組的設定執行 `pg_basebackup --target=shell:`*`DETAIL_STRING`*，讓伺服器管理者選定的伺服器端指令針對備份程序產生的每個 tar 封存檔執行。該指令會從標準輸入接收封存檔內容。

本模組主要用來示範如何透過延伸模組建立新的備份目標，但在某些情境下也可直接使用。若要運作，必須透過 [shared\_preload\_libraries](/15/server-administration/server-configuration/client-connection-defaults.md#GUC-SHARED-PRELOAD-LIBRARIES) 或 [local\_preload\_libraries](/15/server-administration/server-configuration/client-connection-defaults.md#GUC-LOCAL-PRELOAD-LIBRARIES) 載入此模組。

### F.5.1. Configuration Parameters

`basebackup_to_shell.command` (`string`)

伺服器應針對備份程序產生的每個封存檔執行的指令。指令字串中的 `%f` 會替換為封存檔名稱，例如 `base.tar`。`%d` 會替換為使用者提供的目標詳細資訊。若指令字串使用 `%d`，就必須提供目標詳細資訊；否則禁止提供。基於安全考量，目標詳細資訊只能含英數字元。指令字串中的 `%%` 會替換為單一 `%`。若 `%` 後接其他字元，或位於字串末尾，會發生錯誤。

`basebackup_to_shell.required_role` (`string`)

使用 `shell` 備份目標所需的角色。若未設定，任何複寫使用者都可使用 `shell` 備份目標。

### F.5.2. Author

Robert Haas `<`[`rhaas@postgresql.org`](mailto:rhaas@postgresql.org)`>`

***

原文：[PostgreSQL 15.19 Documentation](https://www.postgresql.org/docs/15/basebackup-to-shell.html)


---

# 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/15/appendixes/additional-supplied-modules/basebackup_to_shell.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.
