PostgreSQL 9.3: „One line – one slave“

Sometimes it happens that you reach a point where you know that things cannot be any more simplistic than they are.

I think in PostgreSQL 9.3 we will pretty much have reached this point when we want to fire up a simple replica. Back in the old times you had to call pg_start_backup, rsync the entire stuff, call pg_stop_backup and finally come up with a recovery.conf file to setup a single slave.

Things have changed and some time ago pg_basebackup has made the life of people so much easier. No more rsync (in the typical case), no more function calls. But still, a normal user had to come up with a simple recovery.conf file to control the recovery process.

However, when you take a look at pg_basebackup you will figure out that the call itself already has all info a user will typically need to write a simple recovery.conf file. So, why not use this info and write a recovery.conf file straight away if desired?

This is exactly what Zoltan has implemented for 9.3:
The patch just got committed recently

What does it mean for a typical user?
If the master database has been configured correctly, it means that a typical PostgreSQL user can add a slave to an existing PostgreSQL replication setup with just ONE line.

All you have to do is to call pg_basebackup with the „-R“ option. A simple recovery.conf file will be written automatically. The only thing left to do now is to fire up your brand new slave (pg_ctl start …).

I guess there is no way to make it even more simplistic.

Hans-Juergen Schoenig
Hans-Jürgen Schönig has 15 years of experience with PostgreSQL. He is consultant and CEO of the company „Cybertec Schönig & Schönig GmbH“ (, which has served countless customers around the globe.