Current situation:

  1. PostgreSQL, streaming replication
  2. Master failed, I created the trigger file. Slave is promoted to new master
  3. After the old master restarted successfully, I have to create base backup and change config to change old master to new slave. (https://wiki.postgresql.org/wiki/Streaming_Replication: How to use/13).

My problem: the data amount is very large (sometimes 100GB), therefore the base backup takes a long time. How to turn the old master to a new slave without basebackup? (For example, with administrator command like pg_switch_xlog().)

1 Answer 1


well, you cannot switch back easily. what you can do is to use the old backup method:

SELECT pg_start_backup('whatever');
rsync the data dir
SELECT pg_stop_backup();

this is the best way as not all the data has to be transported over the network. i definitely recommend this replacement for pg_basebackup because it is the only RELIABLE way to get things back in order (nobody knows for sure what happens before the crash). sure, there might be other tricks out there but i would strongly vote for this method.

  • 1
    Agreed, one has to try other methods only if they have the time and the ability to deal with possible corruption. Nov 26, 2014 at 12:59
  • How about the tricks, If after crash, no update on the old Master => so at the crash time, data on Old Master and old slave are the same. And the a point the old master that you should receive WAL logs from the old Slave (the New master now). Is it possible?
    – Ronaldinho
    Nov 27, 2014 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.