Re: Postgres jobs will not automatically login on Mac OSX

From: David Kerr <dmk(at)mr-paradox(dot)net>
To: Patrick Lademan <mjfrog14(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Postgres jobs will not automatically login on Mac OSX
Date: 2013-11-22 17:35:22
Message-ID: 20131122173521.GA95470@mr-paradox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Nov 21, 2013 at 07:11:46PM -0500, Patrick Lademan wrote:
- That worked!!! Thanks!!!
-
- I have one last problem.
-
- It works correctly at the command line:
- postgres ~
- $ ./pg_backup.sh
-
- User: postgres
- PWD: /Library/PostgreSQL/9.3
- HOME: /Library/PostgreSQL/9.3
- BACKUP_DIR: /Users/backup/postgres/
- BACKUP_DIR_DATED: /Users/backup/postgres/2013-11-21/
- ----- Full backups Begin -----
- Backing up postgres ---> /Users/backup/postgres/2013-11-21/postgres.sql.gz
- Backing up rincon ---> /Users/backup/postgres/2013-11-21/rincon.sql.gz
- ----- Full backups End -----
-
- When I run it as a job in postgres, it fails. Here are the results:
- 662 Failed 1 Thu Nov 21 19:02:38 2013 Thu Nov 21 19:02:38 2013
- 00:00:00.016344
- User: postgres
- PWD: /Library/PostgreSQL/9.3
- HOME: /Library/PostgreSQL/9.3
- BACKUP_DIR: /Users/backup/postgres/
- BACKUP_DIR_DATED: /Users/backup/postgres/2013-11-21/
- ----- Full backups Begin -----
- No schemas returned from database. This could be a password issue.
-
- It is behaving like it could not login to get the schema list.
- Since prompting for a password is not an error message, it is not displayed
- in the error log.
- How can I debug this job?

As a sanity check you might want to add the following to the if statement.
echo "Hostname: ${HOSTNAME}"
echo "Username: ${USERNAME}"

Those may be getting lost when the job is run via cron.

For example:
# If the list of Schemas is empty, display error and abort
if [ "$FULL_BACKUP_QUERY_LIST" = "" ]; then
echo "Hostname: ${HOSTNAME}" # <-------Add
echo "Username: ${USERNAME}" # <-------Add
echo -e "No schemas returned from database. This could be a password
issue."
exit 1
fi

Alternativly, add -x to the top line to enable debugging
#!/bin/bash -x

and then in your cron job output stdout and stderr to a file
0 0 0 0 0 0 backupjob.sh >/tmp/backup.out 2>&1

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Patrick Lademan 2013-11-22 18:01:01 Re: Postgres jobs will not automatically login on Mac OSX
Previous Message Peter Eisentraut 2013-11-22 13:27:17 Re: fork_process.c and OpenSSL