title: How to check if postgresql backup was successful?
body: <p>We have a postgresql database that is backed up nightly from a cron job with a following command:</p>
  
  <pre><code>su postgres -c "pg_dump our_database | gzip &gt; /home/smb/shared/database_backup.bak.gz"
  </code></pre>
  
  <p>recently we had a disk failure that started with a few bad sectors and during that time pg_dump exited with the following errors</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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. </p>
  
  <p>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?</p>