I'm attempting to set up a 3-server chain by leveraging WAL-E. I've done this in the past with replication/wal segments and I'm attempting the exact same method, just with using WAL-E in between.

My replication from a -> b is working perfectly through WAL-E. I specify the S3 bucket and access information and a uploads to S3, and b pulls down segments it may need if streaming falls behind.

I'm having an issue trying to get b to upload segments to S3 for use by server c. I've updated my postgresql.conf on b to be:

wal_level = hot_standby
checkpoint_segments = 10
archive_mode = on
archive_command = '/etc/postgresql/9.2/main/local_backup_script.sh "%p" "%f"'
archive_timeout = 3600
max_wal_senders = 5
wal_keep_segments = 4096
hot_standby = on

My local_backup_script.sh is as follows:


echoerr() { echo "$@" 1>&2; }


`envdir /etc/wal-e.d/env-rep-a /usr/local/bin/wal-e wal-push $1` & pid_1=$!

echoerr "Spawned replication process $pid_1"

wait $pid_1 || let "FAIL+=1"

if [ "$FAIL" == "0" ];
echoerr "Replication success $1 $2"
echoerr "Replication failed $1 $2"

exit "$FAIL"

I am using a different S3 bucket from b -> c so they don't step on each other. I've also verified that wal-e upload works to this bucket by manually calling the script from the pg_xlog directory.

But postgresql NEVER executes archive_command, and I'm not at a loss as to why. I even just tried to print something to STDERR (so it goes to the log), nothing.

Few other points: 1) /var/lib/postgresql/9.2/archive directory is empty (on b) 2) the script permissions have been set properly (owned by postgres and chmod +x)

Anyone have any suggestions on what may be wrong?

1 Answer 1


Streaming replicas don't run archive_command because they do not generate WAL. They just replay the master server's WAL.

You can cascade streaming replicas, where one replica acts as a master for the next. But for fallback WAL archiving they both use the master's WAL stream directly.

So just configure the second replica to use the master's WAL stream.

  • Under this system, what do u recommend to do if the master fails and the first replica gets promoted? Would that second server just start writing wal segments to S3 (so, run the archive_command)?
    – Geesu
    Commented May 7, 2014 at 22:14
  • Yes, it would, so if you're possibly promoting servers you'll want archive_command configured. Commented May 8, 2014 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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