Aborted pg_dump run empties existing archive file

From: Ken Winter <ken(at)sunward(dot)org>
To: PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Aborted pg_dump run empties existing archive file
Date: 2016-05-26 18:48:10
Message-ID: CABV8-AZSPSyGm8+2w1NpjYG88HVAgTY0J0t1g+h3P5e7v=bwKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I just discovered that a run of pg_dump that gets aborted empties any
pre-existing backup file of the same name. It happens whether the run was
deliberately canceled by the user or just failed because of a bad password
(as in the example below).

~/dba$ pg_dump --host=localhost -U ken --format=c
--file=mess_development.bak --no-owner --no-privileges mess_development
Password: <CORRECT PASSWORD ENTERED>

~/dba$ ls -l mess_development.bak
-rw-rw-r-- 1 ken ken *87070* May 26 14:20 mess_development.bak

~/dba$ pg_dump --host=localhost -U ken --format=c
--file=mess_development.bak --no-owner --no-privileges mess_development
Password: <BAD PASSWORD ENTERED>
pg_dump: [archiver (db)] connection to database "mess_development" failed:
FATAL: password authentication failed for user "ken"
FATAL: password authentication failed for user "ken"

~/dba$ ls -l mess_development.bak
-rw-rw-r-- 1 ken ken *0* May 26 14:21 mess_development.bak

~/dba$

This is troubling because I can imagine a disaster scenario where one loses
one's previous backup and, perhaps because of a forgotten password, can't
generate a new one. (This scenario hasn't happened to *me* yet, but seems
like it could.) In general, a failed run of a piece of software should
leave everything unchanged. So maybe this is a bug that needs to be fixed?

~ Ken

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2016-05-26 19:25:58 Re: Aborted pg_dump run empties existing archive file
Previous Message Kevin Grittner 2016-05-26 18:31:27 Re: full text search index