29 October 2021

Monitor automatic backups on OCI using Cloud Control job

For one of our customers, we run Oracle database VM's in OCI. Also, we have Automatic Backups in place and we have a Cloud Control in that environment too.

The issue with automatic backups is, that you have to check in the OCI console or with dbcli commands to verify the result of the backup run.

What you can use, is a Cloud Control job (daily) to run the host command-script:

# note: in cloud control escape the percentage with an extra percentage

fromdate=$(date --date="1 days ago" +"%%Y-%%m-%%d")
outfile=/tmp/daily_check_backup_`hostname`.lst
/opt/oracle/dcs/bin/dbcli list-jobs -f $fromdate -k DBTRegular | grep Regular > $outfile
cat $outfile
ERRCNT=$(grep -v 'Success' $outfile | wc -l);
if [ $ERRCNT -ne 0 ]
then
  exit 4
fi

Note that in Cloud Control you use double percentages to escape percentage.
We check backups from the last day, you may change that.
If you run this job, you may send an email when it fails. You will get the email from Cloud Control.

No comments:

Post a Comment