Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6020833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:37:32+00:00 2026-05-23T03:37:32+00:00

We have a postgresql database that is backed up nightly from a cron job

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:37:32+00:00Added an answer on May 23, 2026 at 3:37 am

    I write the outcome into a logfile, and at the end of the cronjob, I send the content of the logfile to my e-mail address. That way, I’ll know when something went wrong.

    su postgres "pg_dump our_database 2>> $LOG_FILE | gzip > /home/smb/shared/database_backup.bak.gz"
    cat $LOG_FILE | mailx $MAINTAINERS -s "Postgresql backup"
    

    ADDENDUM: if you want to send the e-mail only if anything went wrong, you can check the return code of pg_dump:

    LOG_FILE=/tmp/pgdump.err
    
    if ! pg_dump -U backupuser "our_database" 2> $LOG_FILE 
    then 
        cat $LOG_FILE | mailx 'youremailaddress' -s "Postgresql backup failure!"
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an MS Access application that connects to a PostgreSQL database via
I have a problem with processing all rows from database (PostgreSQL). I get an
I have a postgresql database that has this column structure: Author id name Book
I have a PostgreSQL 8.4 database that is created with the da_DK.utf8 locale. dbname=>
I've got two PostgreSQL databases that have been created using the same sql file.
I have a Postgresql database on which I want to do a few cascading
I have a name of table or view in PostgreSQL database and need to
In PostgreSQL 8.3 database I have bookings table referencing booking_transactions table by ID. So
I have a really big database (running on PostgreSQL) containing a lot of tables
Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.