I have two cron jobs on my AWS server (triggered via crontab -e
) to invoke pg_dump
on specific databases.
The two scripts are identical with the exception of the target database they're backing up ($PG_SRC_DB
). One fails at the pg_dump
command but outputs no errors nor logs:
PGPASSWORD=$PG_SRC_PASSWORD $PG_DUMP_PATH --no-owner $PG_SRC_DB -h $PG_SRC_HOST -p $PG_SRC_PORT -U $PG_SRC_USER > dump.sql
I know this because I've forwarded all stderr and stdout to /tmp/cron.log
and I get the error:
mv: cannot stat 'dump.sql': No such file or directory
This command happens after I've run the pg_dump
and the dump.sql
file should have been created, but fails because pg_dump
fails
I've debugged for hours and have done the following:
- re-directed stderr to stdout to an error log
- invoked
export <PGVAR>
forPGPASSWORD
,PGUSER
,PGHOST
, andPGDATABASE
- set my PATH to whatever my PATH is when I run the script manually in terminal
- use the absolute path to
pg_dump
- use
#!/bin/bash -l
login shell - output
pg_dump
error to a file with... > dump.sql 2> error.log
Both scripts work in terminal when run manually.
I have no idea how else to debug the pg_dump
command as I'm not getting any logs from it.