Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XqbFR-0003ou-2H for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Nov 2014 05:22:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XqbFQ-0008Q8-0X for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Nov 2014 05:22:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XqbFO-0008Q1-W9 for pgsql-bugs@postgresql.org; Tue, 18 Nov 2014 05:22:39 +0000 Received: from [162.253.133.43] (helo=mwork.nabble.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XqbFH-0005KN-Ed for pgsql-bugs@postgresql.org; Tue, 18 Nov 2014 05:22:37 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 6CBCBA597C1 for ; Mon, 17 Nov 2014 21:22:30 -0800 (PST) Date: Mon, 17 Nov 2014 22:22:30 -0700 (MST) From: David G Johnston To: pgsql-bugs@postgresql.org Message-ID: <1416288150110-5827327.post@n5.nabble.com> In-Reply-To: <20141117214211.2475.5375@wrigleys.postgresql.org> References: <20141117214211.2475.5375@wrigleys.postgresql.org> Subject: Re: BUG #11991: dangerous action of pg_dump MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 162.253.133.43 (failed) X-Pg-Spam-Score: 0.5 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org tomek wrote > The following bug has been logged on the website: > > Bug reference: 11991 > Logged by: Tomasz Kimaczynski > Email address: > tomek@ > PostgreSQL version: 9.2.9 > Operating system: Windows 2003,2008,2012 & FreeBSD > Description: > > Recently, I realized pg_dump dangerous activity. In case when no dump is > made because of any error, created file size is 0 bytes. In case when this > file is used in simple backup procedure which make copy of dump file - 0 > bytes files overwrite earlier correct dump files. > And we have no copies. > Conclusion: pg_dump can not create 0 bytes files - it should create > nothing. > I think it's important. Even if this were to be done there are other failure modes that will result in partial dumps. The correct answer is to always keep the last correct dump until the next successful dump completes. This is a minimum acceptable practice. Tools can make your life easier but this special case is more likely to do harm than good if people test a quick fail mode and see their original file remain when it should be clobbered. If anything pg_dump should error if the target dump file already exists. If you are talking about your own copy process than that is your responsibility. Copying files without even rudimentary checks that the dumped file is complete is simply being negligent. In theory you should restore the file and run some queries before declaring it good but at minimum file size and program return code checks are needed. Specifically if the dump file is considerably smaller than previous versions you should not remove the old version automatically. Zero always qualifies but even 100 meg decrease should give pause and prompt human evaluation. David J. -- View this message in context: http://postgresql.nabble.com/BUG-11991-dangerous-action-of-pg-dump-tp5827321p5827327.html Sent from the PostgreSQL - bugs mailing list archive at Nabble.com. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs