Postgresql archive_command on a cascading standby server

postgresql

I've found out that archive_command is only run by postgresql on a master.

If I'm running a cascading replication like:

Master -> Slave1 -> Slave2 and want to archive WAL segments on Slave1, the command is never run.

Is this correct?

If so, what if I just copy (rsync or similar) myself the WAL segments from pg_xlog directory to my archive directory? Could I then use this archive directory as the source for a restore_command in a new slave?

Best Answer

If so, what if I just copy (rsync or similar) myself the WAL segments from pg_xlog directory to my archive directory? Could I then use this archive directory as the source for a restore_command in a new slave?

Yes, you can. You are however responsible for making sure you don't drop any log files while doing this.

For best results you probably want to do the cascading copy/rsync/whatever as part of your restore_command on Slave1.