4

Trying to think of ways to speed up slave creation without master downtime.

The normal way of doing is:

  1. pg_start_backup
  2. rsync database files
  3. pg_stop_backup
  4. rsync wal files and start slave

Since 2 can take a long time over the network, is it safe to:

  1. rsync
  2. pg_start_backup
  3. rsync again
  4. pg_stop_backup
  5. rsync wal files and start slave

?

  • I never heard from pg_start_backup. I backup postgresql by pg_dump-ing it in directory format, and the saving it into git. – peterh - Reinstate Monica Nov 16 '18 at 16:56
  • 1
    @user259412 pg_dump is pretty much useless for creating a slave — which is what the asker is wanting to do. pg_dump gets you a logical copy of the data, whereas master-slave replication relies on the data being physically stored in the same way — otherwise the differences transmitted won’t apply. – Colin 't Hart Oct 19 '19 at 4:15
  • @Colin'tHart Sorry, I thought he is about backuping postgresql and not about clustering. – peterh - Reinstate Monica Oct 19 '19 at 20:54
2

Yes, completely safe. The subsequent rsync performed under snapshot conditions will ensure that the data is properly aligned using the delta method.

One might want to ensure that there isn't an accumulation of irrelevant data files by using the --delete option (think carefully about what you are excluding) but this is a mostly separate issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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