Re: somewhat wrong archive_command example - Mailing list pgsql-docs

From Peter Eisentraut
Subject Re: somewhat wrong archive_command example
Date
Msg-id 1316613536.14119.6.camel@fsopti579.F-Secure.com
Whole thread Raw
In response to Re: somewhat wrong archive_command example  (Greg Smith <greg@2ndQuadrant.com>)
Responses Re: somewhat wrong archive_command example
List pgsql-docs
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.



pgsql-docs by date:

Previous
From: "Stefan Wolf"
Date:
Subject: Documentation 9.1 - can't be searched
Next
From: "Kevin Grittner"
Date:
Subject: Re: coalesce