Edit file File name : check_a2_omni_mysql_backup.sh Content :#!/bin/bash # # mysql_backup_check.sh a bash script that checks if the backup of databases defined in $MONITORED_DB were successful # it monitors mysql backups that are created by /opt/bin/mysql_backup.sh script # REF: SYSENG-23785 # author: mfranczak@a2hosting.com # Comma separated list of the backups of databases we want to monitor. MONITORED_DB="omni,supersekrit,mysql,information_schema" # Backup location BACKUP_LOCATION="/opt/backup/" FAILED_BCKP='' # Set the Internal Field Separator (IFS) to a comma IFS=',' # Convert the variable into an array read -ra DBS <<< "$MONITORED_DB" # Loop through the array of monitored DBs and echo each value separately for DB in "${DBS[@]}"; do ERROR=$(find "${BACKUP_LOCATION}" -type f -name ".backup_failed_${DB}" | wc -l) # Alert if backup number is 0 if [ "${ERROR}" != "0" ]; then if [ -z "${FAILED_BCKP}" ]; then FAILED_BCKP="${DB}" else FAILED_BCKP="${FAILED_BCKP}, ${DB}" fi fi done if [ -z "${FAILED_BCKP}" ]; then echo "check_a2_omni_mysql_backup.sh - mysql backups successful" exit 0 else echo "check_a2_omni_mysql_backup.sh - backup of the database ${FAILED_BCKP} failed" exit 2 fi Save