Re: somewhat wrong archive_command example

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Josh Kupershmidt <schmiddy(at)gmail(dot)com>, Greg Smith <greg(at)2ndquadrant(dot)com>, Euler Taveira de Oliveira <euler(at)timbira(dot)com>, pgsql-docs(at)postgresql(dot)org
Subject: Re: somewhat wrong archive_command example
Date: 2012-08-17 19:51:44
Message-ID: 502EA0D0.10004@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On 8/15/12 9:13 PM, Bruce Momjian wrote:
>> Few more suggestions/nitpicks:
>> 1.) IMO it's more logical to put the test for whether the $ARCHIVE
>> directory exists before the test whether ${ARCHIVE}/${FILE} exists.
>> 2.) I think the error code reporting here is not sound:
>>
>> cp ${FULLPATH} ${ARCHIVE}/${FILE}
>> if [ $? -ne 0 ] ; then
>> echo $0 Archive copy of ${FILE} failed with error $? >&2
>>
>> at least on my OS X machine, that echo produces a message like
>> "./local_backup_script.sh Archive copy of failed with error 0", I
>> guess since $? gets reset to 0 after that if-statement. You can use a
>> temporary variable like $ERRCODE=$? to get around this.
>
> I have made all the suggestions posted and would like to add the
> attached script to our documentation as a simple example.

Btw., is anyone else concerned about using plain cp for this? If the cp
fails half-way, it leaves a partial file around, but subsequent file
existence checks will find the file OK and skip it.

I have occasionally used some combination of mktemp + cp + mv, which
seems to work around this problem.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Peter Eisentraut 2012-08-17 20:03:42 Re: Would like to contribute a section to docs for 9.3. Where to start?
Previous Message Heikki Linnakangas 2012-08-17 08:54:54 Re: Clarification suggestion for 46.4 chapter.