khushi singla
khushi singla

Reputation: 1

how to fix the problem of zero bytes file getting generated when using pg_dump through cron job for regular backup?

while taking a backup of Postgres database using the pg_dump tool in a shell script, if I schedule the script in cron then a backup file of 0 bytes gets generated.

On generating error logs using 2>&1 in cron job, the following error file gets generated :

/home/sample_bkp.sh: 10: /home/sample_bkp.sh: -d: not found backup directory: /home/bkp/2019_06_24_17_15 creating backup of phhc database pg_dump: server version: 9.2.4; pg_dump version: 9.1.24 pg_dump: aborting because of server version mismatch pg_dump: *** aborted because of error

Upvotes: 0

Views: 3279

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246568

The key message seems to be:

pg_dump: aborting because of server version mismatch

That means that the version of pg_dump is older than the version of the database you are trying to backup.

Since you say that it only happens from cron, something in the environment must cause a wrong pg_dump to be chosen.

The problem is made more difficult because of the Ubuntu distribution's wrapper scripts that then call the actual executable.

One simple attempt would be to uninstall old PostgreSQL versions that you do not use any more.

Another idea would be to call pg_dump with an absolute path to the correct executable.

Upvotes: 1

Related Questions