From: | alexandre - aldeia digital <alexandre(at)ad2(dot)com(dot)br> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: pg_dump error codes |
Date: | 2006-01-02 20:44:42 |
Message-ID: | 43B990BA.8080505@ad2.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Michael Fuhr wrote:
> On Mon, Jan 02, 2006 at 08:45:28AM -0200, 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 ?
>
> This is more of a shell scripting question than a PostgreSQL question.
> See your shell's documentation and read about I/O redirection and
> control structures like "if".
I know, but I don't found if the pg_dump returns some error code after a
problem.
>
> Here's a simple but only minimally-tested example that might give
> you some ideas:
>
> #!/bin/sh
>
> dumpout=/tmp/dump.out.$$
> dumperr=/tmp/dump.err.$$
> erruser=root
>
> trap "rm -f $dumperr $dumpout; exit" 1 2 15
>
> if ! pg_dump "$@" > $dumpout 2> $dumperr
> then
> rm -f $dumpout
> mail -s "Dump errors" $erruser < $dumperr
> fi
>
> rm -f $dumperr
>
Thank you very much! :)
This is all I need...
Alexandre
From | Date | Subject | |
---|---|---|---|
Next Message | Ardian Xharra (Boxxo) | 2006-01-02 20:48:51 | Query in postgreSQL version Windows |
Previous Message | Ardian Xharra | 2006-01-02 19:38:40 | Query in postgreSQL version Windows |