Search code examples
postgresqlpg-dumpall

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


I have a kubernetes cluster and I have configured a statefulset with two replicas (lets say postgres-0 and postgres-1), one will be active and another will be standby for a perticular time. Now I want to run pg_dumpall from postgres-1 to connect to postgres-0 by specifying certificates (which I already created). I am able to dump a particular database using :

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

I need to do the same with pg_dumpall. Is there any to do that? Ref: https://www.postgresql.org/docs/9.2/app-pg-dumpall.html


Solution

  • Sure, but you have to use the connect string as an argument to the -d option:

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