#!/bin/bash

echo "these are the boxes with paused backups, please get these issues fixed so that we have complete backups for every customer every night"
echo "the suggested method to find out why backups didn't autoresume is to do a 'grep backupmgr /var/log/messages |tail' on the respective customer box"
mysql backups -e 'select hostname,`backup-stage` from backupstate where `backup-stage` like "%Paused" and hostname not like "%alpha%" and hostname not like "%beta%"  and hostname not like "box648%" and hostname not like "box702%" and `cpanel-accounts-total` > 0 order by `mountpoint-problems` desc'

echo -e "\n\nALSO, these boxes haven't had a customer get backups run on them for over 3 days, something is wrong and needs to get investigated"
#mysql backups -e 'select hostname,from_unixtime(`postbackup.log-date`) as last_time_cpanel_user_backed_up  from backupstate where `postbackup.log-date` < ( unix_timestamp(now()) - 259200) and hostname not like "%alpha%" and hostname not like "%beta%"  and hostname not like "box648%" and hostname not like "box702%" and `cpanel-accounts-total` > 0 order by `last_time_cpanel_user_backed_up` asc'
mysql -t backups -e 'select hostname,`cpanel-accounts-not-backuped-up` as accounts_without_backups, from_unixtime(`postbackup.log-date`) as last_time_cpanel_user_backed_up  from backupstate where `cpanel-accounts-not-backuped-up` > 0 and hostname not like "%alpha%" and hostname not like "%beta%"  and hostname not like "box648%" and hostname not like "box702%" and `cpanel-accounts-total` > 0 order by `cpanel-accounts-not-backuped-up` desc;'
