在单独的服务器上安装 Barman。您安装 Barman 的服务器必须能够通过 TCP 与 AlloyDB Omni 服务器进行通信。
将 AlloyDB Omni 配置为与 Barman 配合使用
如需准备好 AlloyDB Omni 服务器以便与 Barman 配合使用,请在安装了 AlloyDB Omni 的服务器上运行以下命令。
创建具有适当权限的 barman 数据库用户:
Docker
dockerexecCONTAINER_NAMEpsql-hlocalhost-Upostgres-c"CREATE USER barman;GRANT EXECUTE ON FUNCTION pg_backup_start(text, boolean) to barman;GRANT EXECUTE ON FUNCTION pg_backup_stop(boolean) to barman;GRANT EXECUTE ON FUNCTION pg_switch_wal() to barman;GRANT EXECUTE ON FUNCTION pg_create_restore_point(text) to barman;GRANT pg_read_all_settings TO barman;GRANT pg_read_all_stats TO barman;CREATE USER streaming_barman WITH REPLICATION;"
将 CONTAINER_NAME 替换为您在安装 AlloyDB Omni 容器时为其分配的名称。
Podman
podmanexecCONTAINER_NAMEpsql-hlocalhost-Upostgres-c"CREATE USER barman;GRANT EXECUTE ON FUNCTION pg_backup_start(text, boolean) to barman;GRANT EXECUTE ON FUNCTION pg_backup_stop(boolean) to barman;GRANT EXECUTE ON FUNCTION pg_switch_wal() to barman;GRANT EXECUTE ON FUNCTION pg_create_restore_point(text) to barman;GRANT pg_read_all_settings TO barman;GRANT pg_read_all_stats TO barman;CREATE USER streaming_barman WITH REPLICATION;"
将 CONTAINER_NAME 替换为您在安装 AlloyDB Omni 容器时为其分配的名称。
在 DATA_DIR/pg_hba.conf 文件中,将以下代码行添加到文件中存在的 host all all all scram-sha-256 行之前:
host all barman BARMAN_IP/32 AUTHN_METHOD
host replication streaming_barman BARMAN_IP/32 AUTHN_METHOD
替换以下内容:
DATA_DIR:用于 AlloyDB Omni 数据目录的文件系统路径。
BARMAN_IP:Barman 服务器的 IP 地址。
AUTHN_METHOD:AlloyDB for PostgreSQL 服务器期望从 Barman 服务器实现的 PostgreSQL 身份验证方法。我们建议使用以下值之一:
dockerexecCONTAINER_NAMEpsql-hlocalhost-Upostgres-c"SELECT name, setting FROM pg_catalog.pg_settings WHERE name IN ('archive_command', 'archive_mode', 'listen_addresses', 'wal_level') ORDER BY name;"
Podman
podmanexecCONTAINER_NAMEpsql-hlocalhost-Upostgres-c"SELECT name, setting FROM pg_catalog.pg_settings WHERE name IN ('archive_command', 'archive_mode', 'listen_addresses', 'wal_level') ORDER BY name;"
输出如下所示:
name | setting
------------------|-----------
archive_command | /bin/true
archive_mode | on
listen_addresses | *
wal_level | replica
(4 rows)
设置 Barman 备份服务器
如需设置和配置 Barman 以与 AlloyDB Omni 服务器配合使用,请在 Barman 服务器上运行以下命令。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-22。"],[[["\u003cp\u003eThis guide outlines the steps to configure AlloyDB Omni to work with Barman, an open-source database backup server, for data protection.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating specific database users (\u003ccode\u003ebarman\u003c/code\u003e, \u003ccode\u003estreaming_barman\u003c/code\u003e) within AlloyDB Omni and granting them necessary privileges.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration of the \u003ccode\u003epg_hba.conf\u003c/code\u003e and \u003ccode\u003epostgresql.conf\u003c/code\u003e files within the AlloyDB Omni data directory is required to enable connections from the Barman server and set up data archiving.\u003c/p\u003e\n"],["\u003cp\u003eThe setup also requires verification of the connection between the Barman server and the AlloyDB Omni server using \u003ccode\u003epsql\u003c/code\u003e, and the configuration of \u003ccode\u003econninfo\u003c/code\u003e and \u003ccode\u003estreaming_conninfo\u003c/code\u003e within the Barman configuration files.\u003c/p\u003e\n"],["\u003cp\u003eAfter initial setup, the \u003ccode\u003ebarman receive-wal\u003c/code\u003e command is used to create a replication slot and begin streaming data from the AlloyDB Omni server to the Barman backup server, allowing subsequent use of the \u003ccode\u003ebarman backup\u003c/code\u003e and other similar commands.\u003c/p\u003e\n"]]],[],null,["# Set up Barman for AlloyDB Omni\n\nSelect a documentation version: Current (16.8.0)keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/install-configure-barman)\n- [16.8.0](/alloydb/omni/16.8.0/docs/install-configure-barman)\n- [16.3.0](/alloydb/omni/16.3.0/docs/install-configure-barman)\n- [15.12.0](/alloydb/omni/15.12.0/docs/install-configure-barman)\n- [15.7.1](/alloydb/omni/15.7.1/docs/install-configure-barman)\n- [15.7.0](/alloydb/omni/15.7.0/docs/install-configure-barman)\n- [15.5.5](/alloydb/omni/15.5.5/docs/install-configure-barman)\n- [15.5.4](/alloydb/omni/15.5.4/docs/install-configure-barman)\n- [15.5.2](/alloydb/omni/15.5.2/docs/install-configure-barman)\n\n\u003cbr /\u003e\n\nThis page shows you how to protect your data by configuring AlloyDB Omni to work with [Barman](https://pgbarman.org/), an open-source database backup server.\n\n\u003cbr /\u003e\n\n\n| The information on this page applies only to AlloyDB Omni for containers. It does not apply to AlloyDB Omni for Kubernetes.\n\n\u003cbr /\u003e\n\nYou can protect your AlloyDB Omni data using any database backup technology that works with PostgreSQL. For example, you can configure AlloyDB Omni to allow\nconnections from a Barman server that you control. This enables the Barman server to perform continuous backups of the data stored in your AlloyDB Omni server.\n\nAfter you configure your Barman and AlloyDB Omni servers to work together, you can subsequently [run Barman commands](https://docs.pgbarman.org/release/latest/#general-commands) to accomplish a variety of data-protection and disaster-recovery tasks, including the following:\n\n- Create an on-demand backup of your data.\n- Set up synchronous WAL streaming of your data changes to your backup server.\n- Restore from a specific backup.\n- Perform a point-in-time restoration.\n\nFor more information about the operation of Barman, see [the Barman manual](https://docs.pgbarman.org/release/latest/).\n\nBefore you begin\n----------------\n\nBefore configuring AlloyDB Omni to work with Barman, you need the following:\n\n- [AlloyDB Omni installed and running](/alloydb/omni/current/docs/install) on a server that you control.\n\n- [Barman installed](https://docs.pgbarman.org/release/latest/#installation) on a separate server. The server that you installed Barman on must be able to communicate with the AlloyDB Omni server over TCP.\n\nConfigure AlloyDB Omni to work with Barman\n------------------------------------------\n\nTo prepare your AlloyDB Omni server to work with Barman, run the following commands on the server where you have\ninstalled AlloyDB Omni.\n\n1. Create the `barman` database user, with the appropriate privileges:\n\n ### Docker\n\n docker exec \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e psql -h localhost -U postgres -c \"\n CREATE USER barman;\n GRANT EXECUTE ON FUNCTION pg_backup_start(text, boolean) to barman;\n GRANT EXECUTE ON FUNCTION pg_backup_stop(boolean) to barman;\n GRANT EXECUTE ON FUNCTION pg_switch_wal() to barman;\n GRANT EXECUTE ON FUNCTION pg_create_restore_point(text) to barman;\n GRANT pg_read_all_settings TO barman;\n GRANT pg_read_all_stats TO barman;\n CREATE USER streaming_barman WITH REPLICATION;\n \"\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name that you assigned to the AlloyDB Omni container when you installed it.\n\n ### Podman\n\n podman exec \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e psql -h localhost -U postgres -c \"\n CREATE USER barman;\n GRANT EXECUTE ON FUNCTION pg_backup_start(text, boolean) to barman;\n GRANT EXECUTE ON FUNCTION pg_backup_stop(boolean) to barman;\n GRANT EXECUTE ON FUNCTION pg_switch_wal() to barman;\n GRANT EXECUTE ON FUNCTION pg_create_restore_point(text) to barman;\n GRANT pg_read_all_settings TO barman;\n GRANT pg_read_all_stats TO barman;\n CREATE USER streaming_barman WITH REPLICATION;\n \"\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name that you assigned to the AlloyDB Omni container when you installed it.\n2. Add the following lines in the \u003cvar translate=\"no\"\u003eDATA_DIR\u003c/var\u003e`/pg_hba.conf` file **before** the `host all all all scram-sha-256` line that exists in the file:\n\n host all barman \u003cvar translate=\"no\"\u003eBARMAN_IP\u003c/var\u003e/32 \u003cvar translate=\"no\"\u003eAUTHN_METHOD\u003c/var\u003e\n host replication streaming_barman \u003cvar translate=\"no\"\u003eBARMAN_IP\u003c/var\u003e/32 \u003cvar translate=\"no\"\u003eAUTHN_METHOD\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDATA_DIR\u003c/var\u003e: the file system path used for the AlloyDB Omni data directory.\n\n - \u003cvar translate=\"no\"\u003eBARMAN_IP\u003c/var\u003e: the IP address of the Barman server.\n\n - \u003cvar translate=\"no\"\u003eAUTHN_METHOD\u003c/var\u003e: the PostgreSQL authentication method\n that your AlloyDB for PostgreSQL server expects from the Barman server.\n We recommend one of the following values:\n\n - To allow the Barman server to authenticate without a password, use `trust`.\n\n - To require a password from the Barman server, use `scram-sha-256`.\n\n3. Add the following lines to the \u003cvar translate=\"no\"\u003eDATA_DIR\u003c/var\u003e`/postgresql.conf` file:\n\n archive_command='/bin/true'\n archive_mode=on\n listen_addresses='*'\n wal_level='replica'\n\n4. Restart the AlloyDB Omni service:\n\n ### Docker\n\n docker restart \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e\n\n ### Podman\n\n podman restart \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name that you assigned to the AlloyDB Omni container when you installed it.\n5. Confirm the necessary parameters are all set appropriately by running\n the following command:\n\n ### Docker\n\n docker exec \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e psql -h localhost -U postgres -c \"\n SELECT name, setting\n FROM pg_catalog.pg_settings\n WHERE name IN ('archive_command',\n 'archive_mode',\n 'listen_addresses',\n 'wal_level')\n ORDER BY name;\"\n\n ### Podman\n\n podman exec \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e psql -h localhost -U postgres -c \"\n SELECT name, setting\n FROM pg_catalog.pg_settings\n WHERE name IN ('archive_command',\n 'archive_mode',\n 'listen_addresses',\n 'wal_level')\n ORDER BY name;\"\n\n The output is as follows: \n\n name | setting\n ------------------|-----------\n archive_command | /bin/true\n archive_mode | on\n listen_addresses | *\n wal_level | replica\n (4 rows)\n\nSet up the Barman backup server\n-------------------------------\n\nTo set up and configure Barman to work with your AlloyDB Omni server,\nrun the following commands on your Barman server.\n\n1. Verify that the streaming replication connection works:\n\n psql -h \u003cvar translate=\"no\"\u003eDATABASE_IP\u003c/var\u003e -U streaming_barman -c \"IDENTIFY_SYSTEM\" replication=1\n\n The output is similar to the following: \n\n systemid | timeline | xlogpos | dbname\n ---------------------+----------+------------+--------\n 7265722823667040273 | 1 | 0/1F0AFCD0 |\n (1 row)\n\n2. Ensure that Barman can connect to the AlloyDB Omni server as the `barman` database user.\n\n psql -t -h \u003cvar translate=\"no\"\u003eDATABASE_IP\u003c/var\u003e -U barman -d postgres -c \"SELECT 'Connected as: '||current_user\"\n\n Replace \u003cvar translate=\"no\"\u003eDATABASE_IP\u003c/var\u003e with the IP address of your AlloyDB Omni server.\n\n The output is similar to the following: \n\n Connected as: barman\n\n3. [Configure the Barman backup server](https://docs.pgbarman.org/release/latest/#setup-of-a-new-server-in-barman) according to your needs and preferences.\n\n Your configuration must include the following settings:\n - Set `conninfo` to connect to the AlloyDB Omni `postgres` database as the `barman` user.\n - Set `streaming_conninfo` to use the `streaming_barman` user.\n - Configure other directives required to enable WAL streaming, as directed by the Barman documentation.\n\n The following minimal but complete example modifies [a streaming-configuration example from the Barman documentation](https://docs.pgbarman.org/release/latest#examples-of-configuration): \n\n [\u003cvar translate=\"no\"\u003eCONFIGURATION_TAG\u003c/var\u003e]\n description = \"Backup settings for my AlloyDB Omni server\"\n conninfo = host=\u003cvar translate=\"no\"\u003eDATABASE_IP\u003c/var\u003e user=barman dbname=postgres\n streaming_conninfo = host=\u003cvar translate=\"no\"\u003eDATABASE_IP\u003c/var\u003e user=streaming_barman\n backup_method = postgres\n streaming_archiver = on\n slot_name = barman\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCONFIGURATION_TAG\u003c/var\u003e: a short tag to identify this server configuration when running `barman` commands---for example, `omni`.\n\n - \u003cvar translate=\"no\"\u003eDATABASE_IP\u003c/var\u003e: the IP address of your AlloyDB Omni server.\n\n4. Switch to the `barman` user.\n\n sudo su - barman\n\n5. Use [the `barman receive-wal` command](https://docs.pgbarman.org/release/3.10.0/#receive-wal) to create a replication slot, and then\n begin receiving a WAL stream from the database server:\n\n barman receive-wal --create-slot \u003cvar translate=\"no\"\u003eCONFIGURATION_TAG\u003c/var\u003e\n barman receive-wal \u003cvar translate=\"no\"\u003eCONFIGURATION_TAG\u003c/var\u003e &\n\n Replace \u003cvar translate=\"no\"\u003eCONFIGURATION_TAG\u003c/var\u003e with the configuration tag that you chose in the previous step.\n\nBarman is now configured to work with your AlloyDB Omni server.\nTo check the replication status, create manual backups, and perform other tasks,\nsee [General commands](https://docs.pgbarman.org/release/latest/#general-commands).\n\nFor example, to create a manual backup, run [the `barman backup` command](https://docs.pgbarman.org/release/latest/#backup).\n\nWhat's next\n-----------\n\n- [Restore an AlloyDB Omni cluster using Barman](/alloydb/omni/current/docs/clone-omni-barman)"]]