We have a postgresql database that is backed up nightly from a cron job with a following command:
su postgres -c "pg_dump our_database | gzip > /home/smb/shared/database_backup.bak.gz"
recently we had a disk failure that started with a few bad sectors and during that time pg_dump exited with the following errors
pg_dump: SQL command failed
pg_dump: Error message from server: ERROR: catalog is missing 17 attribute(s) from relid 20158
pd_dump: The command was: LOCK TABLE public.obvez IN ACCESS SHARE MODE
Now, since it was in cron job, nobody noticed error messages, the backup was interrupted but it wasn't zero sized, everything seemed ok and the error went unnoticed until final disk failure when we realized we didn't have backup.
We managed to restore data from an older backup but now I would like to know what would be the proper way to check if pg_dump finished its job with success or not?