Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A0BCBB5DBDC for ; Fri, 17 Jun 2011 14:26:59 -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 09768-08 for ; Fri, 17 Jun 2011 17:26:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailhub1.renesys.com (mailhub1.ep.renesys.com [195.160.236.248]) by mail.postgresql.org (Postfix) with ESMTP id 48914B5DBC0 for ; Fri, 17 Jun 2011 14:26:53 -0300 (ADT) Received: from ops05.psm1.renesys.com (ops05.psm1.renesys.com [10.200.1.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub1.renesys.com (Postfix) with ESMTP id 4E441671A4; Fri, 17 Jun 2011 17:26:51 +0000 (UTC) Received: (from rouilj@localhost) by ops05.psm1.renesys.com (8.13.8/8.13.8/Submit) id p5HHQoTE022202; Fri, 17 Jun 2011 17:26:50 GMT Date: Fri, 17 Jun 2011 17:26:50 +0000 From: John Rouillard To: Tim Cc: pgsql-admin@postgresql.org Subject: Re: archive_command vs. cp -i Message-ID: <20110617172650.GG26732@renesys.com> References: <20110617084057.238070@gmx.net> <4DFB3B68020000250003E7EA@gw.wicourts.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/110 X-Sequence-Number: 37736 Hi all: Corrected the top posting. On Fri, Jun 17, 2011 at 12:55:07PM -0400, Tim wrote: > On Fri, Jun 17, 2011 at 12:32 PM, Kevin Grittner > Kevin.Grittner@wicourts.gov> wrote: > > "Martin Münstermann" wrote: > > > while setting up a new linux postgresql server, I checked my > > > archive_command. I noticed that the usual "cp -i f1 f2 < > > > /dev/null" did NOT as expected: It did not overwrite the file > > > (PASS), but it returned zero (FAIL, should return error). > > > > > > This could be reproduced on CentOS 5.6, RHEL4, and Ubuntu 10.04. > > I've confirmed on SLES 10 and Ubuntu 9, too. Not really surprising since choosing to not copy a file isn't really an indication of an error when copying a file so... I get the same result (0 exit status) on solaris 8 and solaris 10 with /bin/cp. I wonder what platform the example worked on. > > > Should the BACKUP-ARCHIVING-WAL doc be changed? > > > > I think so. Given the wide variety of platforms on which the > > example could silently cause data loss, I *really* don't think we > > want that in our docs. Someone could blithely copy it into > > production without testing and not know they had it wrong until a > > backup failed to restore. For what it's worth I strongly agree. > Technically the documentation covers its self by saying: > "This is an example, not a recommendation, and might not work on all > platforms." > What would be nice is if the documentation could be made more useful by > providing some more complex example scripts. > What do our readers use for WAL archiving? 'test ! -f /var/bak/pgsql/%f && cp %p /var/bak/pgsql/%f' Which does have a slight race condition as the output file could be created between the test finishing and the cp starting. But the only way that is likely to happen is if postgresql tried to run two identical archive commands in parallel, and I think I would have other issues if that was happening. The following may be safer if you are using a shell with noclobber, or it may not be. Depends on the race conditions in how the shell implements the noclobber code. 'sh -c "set -o noclobber; cat %p > /var/bak/pgsql/%f"' -- -- rouilj John Rouillard System Administrator Renesys Corporation