有没有办法通过指定证书从远程主机使用 pg_dumpall 转储整个 postgres 数据库?

Is there a way to dump the whole postgres db using pg_dumpall from remote host by specifying certificates?

我有一个 kubernetes 集群,我配置了一个有两个副本的状态集(假设是 postgres-0 和 postgres-1),一个将处于活动状态,另一个将在特定时间内待机。现在我想通过指定证书(我已经创建)从 postgres-1 运行 pg_dumpall 连接到 postgres-0。 我可以使用 :

转储特定数据库

pg_dump "port=5432 host=10.20.30.40 user=postgres dbname=test sslcert=pg.cert.pem sslkey=pg.key.pem sslrootcert=ca.crt sslmode=verify-ca" -f test.sql

我需要对 pg_dumpall 做同样的事情。有什么办法吗? 参考:https://www.postgresql.org/docs/9.2/app-pg-dumpall.html

当然可以,但是您必须使用连接字符串作为 -d 选项的参数:

pg_dumpall -d 'host=... port=... ...' -f test.sql