2

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?

1

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.

| improve this answer | |
1

Note that if you are on Postgres 9.5 or 9.6, you can make this work.

On the standby, you need to set archive_mode = always. When Postgres sees archive_mode = on it will only archive WAL as the master, but always tells it to archive WAL even as a standby. The last section of these docs describes this behavior.

Of course the standby needs other suitable config to go along with that, e.g.:

archive_mode = always
hot_standby = on
wal_level = replica
max_wal_senders = 3
archive_command = whatever-you-like
archive_timeout = 300

Basically if you tell the standby to always archive WAL, then it will obey archive_command as normal, so configure things accordingly.

| improve this answer | |

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.