Re: pg_dump error codes

From: Jon Jensen <jon(at)endpoint(dot)com>
To: alexandre - aldeia digital <alexandre(at)ad2(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump error codes
Date: 2006-01-02 17:33:50
Message-ID: Pine.LNX.4.64.0601021029220.8543@ybpnyubfg.ybpnyqbznva
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2 Jan 2006, alexandre - aldeia digital wrote:

> In my Linux bash backup scripts, I wish to send an e-mail when an error
> occurs in pg_dump proccess. And if possible, I want to send the error output
> via e-mail.
>
> Anybody knows how to capture the output and send this to an e-mail ONLY if an
> error occurs ?

I wrote a generic bash shell script to handle this kind of thing in cron.
See the attachment. As long as the program you're running returns an exit
value of 0 when it succeeds, and a non-zero value when it fails, this will
work. (Thought it's not documented in pg_dump's man page, it does return
sane exit values.)

Just do something like:

/path/to/cron-harness pg_dump your-arguments-here

If pg_dump succeeds, nothing will be output. If it fails, all the normal
output will be returned (and if this is a cron job, mailed to you, by
default).

Check the arguments to mktemp, which may vary on your platform. Any
suggestions or improvements are welcome!

HTH,
Jon

--
Jon Jensen
End Point Corporation
http://www.endpoint.com/
Software development with Interchange, Perl, PostgreSQL, Apache, Linux, ...

Attachment Content-Type Size
cron-harness text/plain 1.1 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-01-02 17:38:42 Re: pg_dump error codes
Previous Message Scott Ribe 2006-01-02 17:19:53 Re: inherits index