Re: How Can I check PostgreSQL backup is successfully or not ?

From: John Gorman <jgorman(at)eldocomp(dot)com>
To: Rick Otten <rottenwindfish(at)gmail(dot)com>, Dinesh Chandra 12108 <Dinesh(dot)Chandra(at)cyient(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: How Can I check PostgreSQL backup is successfully or not ?
Date: 2017-02-27 13:29:14
Message-ID: 0A1B0B276DEE6441A2E68EB66D4540DAD71D12C7@WINEX1.eldocomp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Even though it's not listed in any of the documentation or “pg_dump --help” you can check the return code of the process. A return code greater than 0 (zero) usually indicates a failure

./bin >pg_dump -U dummy_user dummy_database; echo $?
1

From: pgsql-performance-owner(at)postgresql(dot)org [mailto:pgsql-performance-owner(at)postgresql(dot)org] On Behalf Of Rick Otten
Sent: Monday, February 27, 2017 3:36 AM
To: Dinesh Chandra 12108
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] How Can I check PostgreSQL backup is successfully or not ?

Although it doesn't really tell if the pg_dump was successful (you'll need to do a full restore to be sure), I generate an archive list. If that fails, the backup clearly wasn't successful, and if it succeeds, odds are pretty good that it worked:

-- bash code snippet --
archiveList=`pg_restore -l ${backupFolder}`
if [[ ! ${archiveList} =~ "Archive created at" ]]
then
echo "PostgreSQL backup - Archive List Test Failed for ${hostName}:${dbName}"
echo "Archive listing:"
echo ${archiveList}
exit 1
fi
-----------------------

On Mon, Feb 27, 2017 at 4:35 AM, Dinesh Chandra 12108 <Dinesh(dot)Chandra(at)cyient(dot)com<mailto:Dinesh(dot)Chandra(at)cyient(dot)com>> wrote:
Hi,

We are taking daily full backup of PostgreSQL database using PG_DUMP which is automatic scheduled through Cronjobs.

How can I check my yesterday backup is successfully or not?
Is there any query or view by which I can check it?

Regards,
Dinesh Chandra
|Database administrator (Oracle/PostgreSQL)| Cyient Ltd. Noida.
------------------------------------------------------------------
Mobile: +91-9953975849<tel:+91%2099539%2075849> | Ext 1078 |dinesh(dot)chandra(at)cyient(dot)com<mailto:%7Cdinesh(dot)chandra(at)cyient(dot)com>
Plot No. 7, NSEZ, Phase-II ,Noida-Dadri Road, Noida - 201 305,India.

________________________________

DISCLAIMER:

This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Check all attachments for viruses before opening them. All views or opinions presented in this e-mail are those of the author and may not reflect the opinion of Cyient or those of our affiliates.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message vinny 2017-02-27 14:00:32 Re: How Can I check PostgreSQL backup is successfully or not ?
Previous Message Rick Otten 2017-02-27 10:36:15 Re: How Can I check PostgreSQL backup is successfully or not ?