Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B4B15B5DCD8 for ; Thu, 22 Sep 2011 15:16:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 54843-01-4 for ; Thu, 22 Sep 2011 18:16:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by mail.postgresql.org (Postfix) with ESMTP id 1C321B5DD77 for ; Thu, 22 Sep 2011 15:15:50 -0300 (ADT) Received: by qyk7 with SMTP id 7so3018014qyk.19 for ; Thu, 22 Sep 2011 11:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=xhJL7u6kiAkQoP7EHF+aQ7LiREmsNXDQY6zEvlVRpxI=; b=DTAd0VgOYCvsj7/cuoH/zSAMZA+PHPdbPLRSEFpHfavoHAj30lyp1MNV35iFp3XeBW QjKrXE8lINPOATCfxAK1/Xzq8YY9JfmH40e+r1NmBzrD+lCliqNasySA/ekv5rI4W+aT zDCYn5pKdBiHrBeZ9mN5ztlJTdmHGqmqQdmvE= Received: by 10.229.81.197 with SMTP id y5mr2081508qck.266.1316715350084; Thu, 22 Sep 2011 11:15:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.213.83 with HTTP; Thu, 22 Sep 2011 11:15:30 -0700 (PDT) In-Reply-To: <4E7A887F.8010908@timbira.com> References: <1316524671.9044.12.camel@fsopti579.F-Secure.com> <4E794FB5.80400@2ndQuadrant.com> <1316613536.14119.6.camel@fsopti579.F-Secure.com> <4E7A6D0D.4060106@2ndQuadrant.com> <4E7A887F.8010908@timbira.com> From: Josh Kupershmidt Date: Thu, 22 Sep 2011 14:15:30 -0400 Message-ID: Subject: Re: somewhat wrong archive_command example To: Greg Smith , Euler Taveira de Oliveira Cc: pgsql-docs@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201109/70 X-Sequence-Number: 6991 On Wed, Sep 21, 2011 at 8:59 PM, Euler Taveira de Oliveira wrote: > On 21-09-2011 20:02, Greg Smith wrote: >> >> Attached version fixes the late night brain fade errors. I think the right >> thing to do next is to package this up into a doc update that corrects the >> errors in that section too; just clean the whole thing up while I'm poking >> at >> it. I'll submit that over to the hackers list so that everyone can take a >> shot >> at correcting my shell code. First, a +1 on the impetus for this script. 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. Josh