Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 8A957B5DC51 for ; Tue, 30 Aug 2011 21:30:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 65360-02 for ; Wed, 31 Aug 2011 00:30:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by mail.postgresql.org (Postfix) with ESMTP id 244BBB5DCD6 for ; Tue, 30 Aug 2011 21:30:13 -0300 (ADT) Received: by qyk34 with SMTP id 34so143066qyk.19 for ; Tue, 30 Aug 2011 17:30:13 -0700 (PDT) Received: by 10.224.196.196 with SMTP id eh4mr3247367qab.65.1314750613534; Tue, 30 Aug 2011 17:30:13 -0700 (PDT) Received: from [10.1.1.8] (124-169-102-162.dyn.iinet.net.au. [124.169.102.162]) by mx.google.com with ESMTPS id fq5sm10882865qab.15.2011.08.30.17.30.11 (version=SSLv3 cipher=OTHER); Tue, 30 Aug 2011 17:30:12 -0700 (PDT) Message-ID: <4E5D8090.9060406@ringerc.id.au> Date: Wed, 31 Aug 2011 08:30:08 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: Karuna Karpe CC: pgsql-admin@postgresql.org Subject: Re: create schedule job References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201108/236 X-Sequence-Number: 38223 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