备份检查小脚本
# cat check_gitlab_bak.sh
#!/bin/sh
source /etc/profile
# 定义邮件发送列表
maillist=(
zise@feizhu.com
)
# 发送邮件函数
send_mail(){
for mail in ${maillist[*]}; do
echo -e "`date +%Y:%m:%d` backups success,\nbackups big $1,\nhost surplus resources $2 " | mail -s "${Title}" $mail
done
}
# 定义需要检测的备份信息的时间
baklist=(
`ls -lt /backups/160* | awk 'NR==1{print $7}'`
)
# 检测是否进行备份
for domain in ${baklist[*]};do
echo "当前的时间: " `date`
time=`date +%d`
echo $domain
backups=`ls -lth /backups/160* | awk 'NR==1{print $5}'`
hoststorage=`df -h | grep -w /dev/vda1 | awk '{print $5}'`
if [ $domain -eq $time ]; then
Title="gitlab bak success"
send_mail $backups $hoststorage $Title
else
Title="gitlab bak failed"
send_mail $backups $hoststorage $Title
fi
done
过手如登山,一步一重天