Re: restore_command ignored in recovery.conf on standby - Mailing list pgsql-general

From Stephen Frost
Subject Re: restore_command ignored in recovery.conf on standby
Date
Msg-id 20140414032247.GU2556@tamriel.snowman.net
Whole thread Raw
In response to Re: restore_command ignored in recovery.conf on standby  (Rene Romero Benavides <rene.romero.b@gmail.com>)
List pgsql-general
Rene,

* Rene Romero Benavides (rene.romero.b@gmail.com) wrote:
> What I did (I bet there's a better way) is this:
> restore_command='/db/standby_node/scripts/wal_restore.sh %f %p'
>
> # wal_restore.sh
> #!/bin/bash
> /bin/tar -xzf /db/wal_archives/$1.tar.gz -C /tmp
> cp /tmp/$1 $2
> rm /tmp/$1

You'll probably want to be more careful here- this script could exit
with 'success' (meaning zero) even if some of the above commands fail.
When writing reliable shell scripts, you really need to check the exit
status of each command.  Note that you can return a high-value (>128,
iirc) from your shell script to indicate 'permanent' failure while
trying to do WAL recovery and PG will give up and stop trying.

Is there any particular reason you're tar'ing up the WAL files in the
first place..?  It'd surely be easier if you simply gzip'd them and then
used something like 'zcat /path/to/wal/archive/%f.gz > %p'.

The other option, if you really want to keep them tar'd, would be to use
tar's -O option, eg:

tar -O -zxf /db/wal_archives/%f.tar.gz %f > %p

There is also a --transform option that you could pass to tar to change
the filenames.

> My best regards to Stephen Frost.

Thanks!

    Stephen

Attachment

pgsql-general by date:

Previous
From: Rene Romero Benavides
Date:
Subject: Re: restore_command ignored in recovery.conf on standby
Next
From: Jeff Janes
Date:
Subject: Re: restore_command ignored in recovery.conf on standby