I am absolutely new to postgres 9.1 replication mechanisms.

I have managed to set up streaming replication between a master and standby postgres (Both have x number of records). At one point when the master server fails, using the trigger file mechanism the standby takes over, and accumulates additional data (say now has x+y number of records).

Now when the Original Master Server comes up, it still has x number of records (which is now the new master). Is there a way to fetch only the delta, i.e. newly added 'y' number of records from the standby and restart as Master.

Or do I have to always take entire base backup?

  • 2
    Look into pg_rewind. In general, you can't be sure that the old master didn't have updates that didn't make it to its slave, so you need to "rewind" the old master first. See for example hlinnaka.iki.fi/2015/03/23/pg_rewind-in-postgresql-9-5 – Colin 't Hart May 5 '15 at 8:51
  • 1
    @Colin'tHart this won't help them until they upgrade to the not-yet-released 9.5 ;) – dezso May 5 '15 at 9:01
  • Yes, but versions for as far as back as at least 9.3 exist at github.com/vmware/pg_rewind – Colin 't Hart May 5 '15 at 9:03
  • The other option is to rsync your original master from (a snapshot of) the slave. This will probably be quicker than backing up the slave and restoring to the original master, but slower than the pg_rewind solution. – Colin 't Hart May 5 '15 at 9:04
  • 2
    @dezso I don't think it's ever possible to set the old master as a slave without restore/rewind. – Jack Douglas May 5 '15 at 9:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.