pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <ringerc@ringerc.id.au>
To: Karuna Karpe <karuna.karpe@os3infotech.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: create schedule job
Date: Wed, 31 Aug 2011 08:30:08 +0800
Message-ID: <4E5D8090.9060406@ringerc.id.au> (raw)
In-Reply-To: <CAC-Lqbrty-6zsvcUoF69mVa_FucRVRBNxGQYOw23bUi+QLg+Kw@mail.gmail.com>
References: <CAC-Lqbrty-6zsvcUoF69mVa_FucRVRBNxGQYOw23bUi+QLg+Kw@mail.gmail.com>

On 30/08/2011 9:29 PM, Karuna Karpe wrote:
> Hello,
>
> I am create one job using pgAgent in postgres studio.  In that job i 
> want to backup whole database every day.  But when i check the backup 
> location, then there is no any backup file created.

Write permissions for PgAgent user to target location?

SELinux involvement?



Also, you seem to be doing both a pg_dumpall that backs up all the 
databases, and individual pg_dump runs for each database. Typically 
you'd do one or the other. If using individual database pg_dump, you 
usually use pg_dumpall with the "--globals-only" option to capture user 
definitions etc.



I recommend that you add error handling to your script. First, add

set -e -u

to the top, so the script treats undefined variables as errors and so 
that it aborts when commands fail. Then add error handling, eg:

$PGBIN/pg_dumpall -h $PGHOST -U $PGUSER | gzip > 
$BACKUPDIR/fullbackup-$themonth.sql.gz

becomes (eg)

if ! "$PGBIN/pg_dumpall" -h "$PGHOST" -U "$PGUSER" | gzip > 
"$BACKUPDIR/fullbackup-$themonth.sql.gz" ; then
   echo >2 "Failed to dump global data from database. Backup FAILED."
   exit 1
fi

Then make *SURE* that cron or pgagent or whatever check the exit status 
of your script and email you the contents of stderr when it fails. Do 
this by temporarily adding:

echo 2>"Manually aborting"
exit 1

to the top of your script and making sure that you get an error email 
containing "Manually aborting" when it is there.

Once that's done, you'll know that if something makes the backup fail, 
you will be notified and the message will contain the error output from 
the failed command.

--
Craig Ringer



view thread (3+ messages)

Message-ID: <4E5D8090.9060406@ringerc.id.au>
Permalink:  ../4E5D8090.9060406@ringerc.id.au/
Also on:    postgresql.org/message-id/4E5D8090.9060406@ringerc.id.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: ringerc@ringerc.id.au, karuna.karpe@os3infotech.com
  Subject: Re: create schedule job
  In-Reply-To: <4E5D8090.9060406@ringerc.id.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox