I have this simple script to backup all my databases in postgres
pg_dumpall -U pg_user > /tmp/tmp.txt DUMP_STATUS=$? echo "Dump status: $DUMP_STATUS" > /tmp/status.txt
The dump status is 0 and the tmp.txt file is properly created when the script is executed from the command line.
However, if I execute this script as a cronjob in my crontab, my tmp.txt is empty (the dump of all databases failed) and my status.txt file contains a dump status 127.
A strange behavior I noticed is that pg_dumpall will pipe the information into the file but also print it on the terminal. I'm thinking this behavior might be the cause of the problem.
Any idea how I can solve this issue?
I am running FreeBSD:
> uname -mrs FreeBSD 9.1-PRERELEASE amd64 > psql -V psql (PostgreSQL) 9.1.7 contains support for command-line editing