public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bruce Momjian <[email protected]>
To: Peter Eisentraut <[email protected]>
Cc: Josh Kupershmidt <[email protected]>
Cc: Greg Smith <[email protected]>
Cc: Euler Taveira de Oliveira <[email protected]>
Cc: [email protected]
Subject: Re: somewhat wrong archive_command example
Date: Sat, 25 Aug 2012 19:07:55 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<CAK3UJRHChOcGQ0kzu01wZX6PB9pScHSzg1X+hThdR7QXWoe1yw@mail.gmail.com>
<[email protected]>
<[email protected]>
On Fri, Aug 17, 2012 at 03:51:44PM -0400, Peter Eisentraut wrote:
> 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.
I am unclear why the script returns success if the file already exists
--- seems if the file exists, we should throw an error, like we have
always done with cp -i < /dev/null.
Updated version attached.
Another option in this case would be to re-issue the copy.
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:
[application/x-sh] local_backup_script.sh (462B, 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], [email protected], [email protected], [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