Postgresql - Failed to run backup file *.sh from Postgresql Enterprise Manager

I tried to run a file below in PostgreSQL Enterprise Manager, it show successful but the backup file was not get created.

Then I try to run it from the terminal which it prompt me below error messages


-bash-4.1$ sh dailybackup.sh
dailybackup.sh: line 11: /usr/bin/pg_dumpall: No such file or directory
dailybackup.sh: line 11: /opt/PostgresPlus/Backup/fullbackup-201309.sql.gz: Permission denied
dailybackup.sh: line 18: /usr/bin/pg_dump: No such file or directory
dailybackup.sh: line 18: /usr/bin/pg_dump: No such file or directory
-bash-4.1$


Below heer is the script for backups

#!/bin/bash
#backup directory can be a file server share that the PgAgent daemon account has access to
BACKUPDIR="/opt/PostgresPlus/Backup"
PGHOST="localhost"
PGUSER="postgres"
PGBIN="/usr/bin"
thedate=`date --date="today" +%Y%m%d%H`
themonth=`date --date="today" +%Y%m`

#create a full backup of the server databases
$PGBIN/pg_dumpall -h $PGHOST -U $PGUSER | gzip > $BACKUPDIR/fullbackup-$themonth.sql.gz

#put the names of the databases you want to create an individual backup below
dbs=(DB1 DB1Snapshot )
#iterate thru dbs in dbs array and backup each one
for db in ${dbs[@]}
do
      $PGBIN/pg_dump -i -h $PGHOST -U $PGUSER -F c -b -v -f $BACKUPDIR/$db-$thedate.compressed $db
done

#this section deletes the previous month of same day backup except for the full server backup
rm -f $BACKUPDIR/*`date --date="last month" +%Y%m%d`*.compressed
motioneyeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

farzanjCommented:
This command appears to have a problem

Issue command
ls -l  /usr/bin/pg_dumpall

Open in new window


Also
ls -ld /opt/PostgresPlus/Backup
ls -l  /usr/bin/pg_dump

Open in new window


Show the results
0
earth man2Commented:
you need to locate where postgresplus executable programs are installed.
set PGBIN shell variable to that location.

Is it /opt/PostgresPlus/bin ?
0
motioneyeAuthor Commented:
Thanks,
I have managed a correct location for the backup. I just wondering one thing.

when I ran the sh script from command line in Linux its working to save a backups, howeveer it prompt me for password when it require access to the database.

I did a same thing from enterprise db manager, but it does not backups any database using the same screen. do you guys have any ideas why it happens ??

Below is the script

#!/bin/bash
#backup directory can be a file server share that the PgAgent daemon account has access to
BACKUPDIR="/opt/PostgresPlus/Backup"
PGHOST="localhost"
PGUSER="postgres"
PGBIN="/opt/PostgresPlus/9.2AS/bin"
thedate=`date --date="today" +%Y%m%d%H`
themonth=`date --date="today" +%Y%m`

#create a full backup of the server databases
$PGBIN/pg_dumpall -p5432  -h $PGHOST -U $PGUSER | gzip > $BACKUPDIR/fullbackup-$themonth.sql.gz

#put the names of the databases you want to create an individual backup below

$PGBIN/pg_dump -i -p5432  -h $PGHOST -U $PGUSER DB1 | gzip > $BACKUPDIR/DB1-$thedate.sql.gz
$PGBIN/pg_dump -i -p5432  -h $PGHOST -U $PGUSER DB1Snapshot | gzip > $BACKUPDIR/DB1Snapshot-$thedate.sql.gz

#this section deletes the previous month of same day backup except for the full server backup
rm -f $BACKUPDIR/*`date --date="last month" +%Y%m%d`*.sql.gz
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

earth man2Commented:
pg_dump has options
-w
or
--no-password

    Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be used in batch jobs and scripts where no user is present
0
motioneyeAuthor Commented:
I tried to run them in job but it failed which I think due to password requirement, how do I run it in job without pg_dump ask for password ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
motioneyeAuthor Commented:
Thanks....it help me at least....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.