创建 pgBackRest stanza 并验证归档(stanza-create/check)
PostgreSQL备份与 PITR命令
# Create the stanza in the repository (once):
sudo -u postgres pgbackrest --stanza=<stanza> --log-level-console=info stanza-create
# Verify configuration and archiving end to end (switches WAL and waits for the segment to reach the repo):
sudo -u postgres pgbackrest --stanza=<stanza> --log-level-console=info check作用
stanza-create 在存储库中创建集群的元数据(system identifier、版本);check 通过一次实际的 WAL 切换测试 PostgreSQL 连接、archive_command 以及 WAL 是否到达存储库。
适用场景
在初始安装时、修改 archive_command 或存储库后,以及作为监控/cron 健康检查。
注意
请以 postgres(或存储库所有者)身份运行命令;以 root 运行会破坏文件属主。大版本升级后需要 stanza-upgrade,而不是 stanza-create。如果 check 失败,即使备份完成,PITR 也可能无法进行。