Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 353C7B5DC09 for ; Wed, 21 Sep 2011 10:59:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 93740-07 for ; Wed, 21 Sep 2011 13:59:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id A973CB5DC0A for ; Wed, 21 Sep 2011 10:58:59 -0300 (ADT) Received: (qmail invoked by alias); 21 Sep 2011 13:58:57 -0000 Received: from fsgw.f-secure.com (EHLO [10.128.133.18]) [193.110.108.33] by mail.gmx.net (mp028) with SMTP; 21 Sep 2011 15:58:57 +0200 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX19YzXo9tGZYNTIvW3WKX/ZEECuK1IjZMo78z1q+g7 9kICj2fS4OpUc3 Subject: Re: somewhat wrong archive_command example From: Peter Eisentraut To: Greg Smith Cc: pgsql-docs@postgresql.org In-Reply-To: <4E794FB5.80400@2ndQuadrant.com> References: <1316524671.9044.12.camel@fsopti579.F-Secure.com> <4E794FB5.80400@2ndQuadrant.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 21 Sep 2011 16:58:56 +0300 Message-ID: <1316613536.14119.6.camel@fsopti579.F-Secure.com> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.403 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/63 X-Sequence-Number: 6984 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.