Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am reading tutorials on how to setup streaming replication in Postgres from master to slave.

Some tutorials recommend setting up archiving in the master (and restoring in slave) . In the master, this needs to be set in the conf file:

wal_level = hot_standby
archive_mode = on
archive_command = 'some rsync command to rsync logfile segments from master to slave'

What is the purpose of this archiving? When is it not necessary when setting up streaming replication?

share|improve this question

WAL archiving is useful when you're running streaming replication, because there's a limit to how much WAL the master will retain.

If you don't archive WAL, and the replica gets s far behind that the master has discarded WAL it still needs, it cannot recover and must be replaced with a fresh base backup from the master.

It's also useful for PITR for disaster recovery purposes.

share|improve this answer
is it too late to setup archiving when I already had the replication from master to slave running for a long time? If I can, should I restart the slave first? – Henley Chiu Feb 10 '14 at 3:23
@HenleyChiu You can start WAL archiving at any time. You'll need to restart the replica to set a recovery.conf entry for the restore_command. The master may also need restarting to set an archive_command. – Craig Ringer Feb 10 '14 at 3:24
should I restart the slave first then the master? – Henley Chiu Feb 10 '14 at 3:46
@HenleyChiu WAL archiving is asynchronous, so it doesn't really matter, does it? – Craig Ringer Feb 10 '14 at 4:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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