Re: somewhat wrong archive_command example

From: Greg Smith <greg(at)2ndQuadrant(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: Re: somewhat wrong archive_command example
Date: 2011-09-21 02:45:09
Message-ID: 4E794FB5.80400@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On 09/20/2011 09:17 AM, Peter Eisentraut wrote:
> At
> http://www.postgresql.org/docs/current/static/continuous-archiving.html
> we say
>
> """
> Many people choose to use scripts to define their archive_command, so
> that their postgresql.conf entry looks very simple:
>
> archive_command = 'local_backup_script.sh'
> """
>
> It seems to me, however, that even a simple archive_command like that
> ought to contain at least %p, right?
>

Yes, you have to pass %p, and even though you can derive it from there
it's easier for most if they get %f too.

That whole section is really problematic. It says "Any messages written
to stderr from the script will appear in the database server log", but
on some platforms things printed to stdout appear there too. And
without an example, it really doesn't make a good case for why a
separate script can be useful in all cases. I've lost count of how many
people I've seen hang themselves with impossible to giant single line
archive_command setups, following the examples that are given; those
blow up quite badly when things go wrong.

Attached is a working local_backup_script.sh that does the same basic
thing as the "Standalone Hot Backups" example. It includes lots of
error checking, useful messages when it doesn't work like this:

Archive directory does not exist
LOG: archive command failed with exit code 1
DETAIL: The failed archive command was: ./local_backup_script.sh
pg_xlog/00000001000000010000007D 00000001000000010000007D

And it takes advantage of the fact that scripts will be executed in
$PGDATA, by putting all the paths it uses relative to it.

If I could get some general agreement this is a good direction to wander
in, I'd be happy to wrap this into a full doc patch and submit it. I've
been meaning to do this for a while and just never got around to it.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us

Attachment Content-Type Size
local_backup_script.sh application/x-sh 675 bytes

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Magnus Hagander 2011-09-21 05:02:43 Re: somewhat wrong archive_command example
Previous Message Fujii Masao 2011-09-21 01:58:31 Re: somewhat wrong archive_command example