Re: restore_command ignored in recovery.conf on standby

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Rene Romero Benavides <rene(dot)romero(dot)b(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: restore_command ignored in recovery.conf on standby
Date: 2014-04-14 03:22:47
Message-ID: 20140414032247.GU2556@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rene,

* Rene Romero Benavides (rene(dot)romero(dot)b(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2014-04-14 04:41:18 Re: restore_command ignored in recovery.conf on standby
Previous Message Rene Romero Benavides 2014-04-14 03:13:17 Re: restore_command ignored in recovery.conf on standby