public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: Greg Smith <[email protected]>
Cc: [email protected]
Subject: Re: somewhat wrong archive_command example
Date: Wed, 21 Sep 2011 16:58:56 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>

On tis, 2011-09-20 at 22:45 -0400, Greg Smith wrote:
> 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. 

I can see a few problems with your script, as far as making it into a
generally reusable example:

- Uses bash.  Portable scripts shouldn't do this.

- Overwrites PATH variable for unrelated purpose.

- Path ($PATH) should be quoted everywhere.  (By contrast, you don't
need the quotes in PATH="$1".  Just saying ...)

- cp shouldn't be called with an absolute path.

I guess this only supports the point that even a small script can
contain lots of traps, so providing a robust example would be helpful.





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], [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