Re: how to detect the backup database every day - Mailing list pgsql-general

From Scott Marlowe
Subject Re: how to detect the backup database every day
Date
Msg-id dcc563d10708070742v36a4de38ue09980d87a860cfa@mail.gmail.com
Whole thread Raw
In response to how to detect the backup database every day  (son@raider.co.nz)
List pgsql-general
On 8/7/07, son@raider.co.nz <son@raider.co.nz> wrote:
> Hello all
>
> I use a crontab job to backup and restore my database every midnight every
> day (using pg_dump and restore...)

Backup from one machine, restore to another, right?

> My cron job run well for a while. However, today I discovered that my
> database was not restored for one month.

> I also fix the problem as there is corruption in the script.
>
> My question is how I can detect whether the backup or restore processes is
> corrupted. I donot want that my backup database is one month old  -:(

You can detect whether backup failed from a bash script like so:

#!/bin/bash
if ( pg_dump dbname ); then
        echo "good";
else
        echo "bad";
fi;

Same thing for pg_restore or psql

> If you have any experience about this please help...

Some.  There are a lot of angles you can approach this from.  You can
have a simple cronjob that runs every day that checks the size / age
of the latest backup and sends an alarm if it's smaller than the last
one, or isn't there, etc...  You can use the find command to look for
files that are less than x seconds / minutes / hours / days old.

pgsql-general by date:

Previous
From: Kenji Morishige
Date:
Subject: Re: finding reusable ids
Next
From: brian
Date:
Subject: Re: how to detect the backup database every day