Re: pg_dump return status..

From: "Anthony E (dot) Greene" <agreene(at)pobox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump return status..
Date: 2001-01-05 05:06:17
Message-ID: 20010105000617.O8784@cp5340
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 04 Jan 2001 05:12:25 Anand Raman wrote:
>I am trying to create a shell script which dumps my db to a flat file ..
>
>To dump the database i use the pg_dump command..
>
>I find that irrespective of the fact whether pg_dump managed to connect
>to the db or not the return status ($?) is always zero.. This throws the
>shell script in a spin which continues even when pg_dump is not able to
>connect ..
>
>Is there anyway around this. I thought of one way was to check stderr
>for the occurence of the word "failed" and then exit..

You could have the script check for the existence of the dump file and that
it has a non-zero size. To dump my personal database, I could use this:

#!/bin/bash
dumpfile=$HOME/mydatabase.dump
pg_dump -d $LOGNAME > $dumpfile
if [ -s $dumpfile ] ; then
echo 'Dump succeeded'
else
echo 'Dump failed'
fi

This should work in sh also.

Tony
--
Anthony E. Greene <agreene(at)pobox(dot)com> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D
Chat: AOL/Yahoo: TonyG05 ICQ: 91183266
Linux. The choice of a GNU Generation. <http://www.linux.org/>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin 2001-01-05 05:37:54 How do I create a check constraint that is based on age difference?
Previous Message Lincoln Yeoh 2001-01-05 05:05:29 Re: Synchronous LISTEN/NOTIFY?