public inbox for [email protected]  
help / color / mirror / Atom feed
From: Greg Smith <[email protected]>
To: [email protected]
Subject: Re: somewhat wrong archive_command example
Date: Tue, 20 Sep 2011 22:45:09 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

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    [email protected]   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us



Attachments:

  [application/x-sh] local_backup_script.sh (675B, 2-local_backup_script.sh)
  download

view thread (24+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: somewhat wrong archive_command example
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox