Postgres: enable pg_basebackup

Created on 2 Sep 2015  路  5Comments  路  Source: docker-library/postgres

moving issue from https://github.com/docker-library/official-images/issues/1020

I'd love to be able to use docker exec to initiate a pg_basebackup that would save a tar.gz backup in a directory on the exposed volume so that I can offsite backups from the container.

Most helpful comment

I added the following to pg_hba.conf:

local replication all md5
host replication all 0.0.0.0/0 md5

But then it needed more configuration with max_wal_senders, and wal_level in postgresql.conf:

-#wal_level = minimal
+wal_level = archive

...

-#max_wal_senders = 0
+max_wal_senders = 2

And then this will work:

$ docker exec some-postgres sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" exec pg_basebackup -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -D /dir/to/save/ -X s'

All 5 comments

I added the following to pg_hba.conf:

local replication all md5
host replication all 0.0.0.0/0 md5

But then it needed more configuration with max_wal_senders, and wal_level in postgresql.conf:

-#wal_level = minimal
+wal_level = archive

...

-#max_wal_senders = 0
+max_wal_senders = 2

And then this will work:

$ docker exec some-postgres sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" exec pg_basebackup -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -D /dir/to/save/ -X s'

Is there any reason this isn't fixed yet? Seems straight forward.

Related #55.

It's not fixed because it's not really a bug -- using "pg_basebackup" with
this image requires some configuration tweaks, just like a normal install
(as @yosifkit has noted above).

I didn't want to imply it's a bug, fix as in something to close this 'issue'. :)
Fair enough, but IMO allowing replication by default shouldn't harm and make configuration tweaks easier? That's why I actually came here. Basically just adding this line host replication replication all md5

Closing, given that this is working as intended -- as documented by upstream, pg_basebackup requires configuration changes in order to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

orion110217 picture orion110217  路  3Comments

note89 picture note89  路  3Comments

qwang07 picture qwang07  路  4Comments

harrybvp picture harrybvp  路  4Comments

phanikumarp picture phanikumarp  路  3Comments