Postgresql – Taking a backup of a streaming WAL slave

postgresqlpostgresql-9.1replication

I have an environment with pair of postgresql servers set up to do WAL streaming replication.

I also have a test environment and periodically I want to snapshot the production DBMS and restore that onto the test server.

Right now I do:

ID=db-$(date +%F_%T)
pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID

and then restore that archive on the test server.

Unfortunately that makes things really slow down on the production server so I'd like to switch that to pulling the clone from the replication slave.

But I can't – the error I get is:

pg_basebackup: could not connect to server: FATAL: recovery is still in progress, can't accept WAL streaming connections

What do I need to do to accomplish my goal of not killing performance on the master when I need to clone it?


Running on Ubuntu 12.04 x86_64, postgresql server 9.1.9-0ubuntu12.04

Best Answer

Chained replication is supported on PostgreSQL 9.2.

9.1 does not support chained replication. You will need to either take the base backup from the master, or:

  • Stop the replica
  • Copy the replica manually
  • Start the replica back up