Re: pg_dump error codes
От | Jon Jensen |
---|---|
Тема | Re: pg_dump error codes |
Дата | |
Msg-id | Pine.LNX.4.64.0601021029220.8543@ybpnyubfg.ybpnyqbznva обсуждение исходный текст |
Ответ на | pg_dump error codes (alexandre - aldeia digital <alexandre@ad2.com.br>) |
Список | 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, ...
Вложения
В списке pgsql-general по дате отправления: