#!/bin/bash
# author:佛系城堡孩子王
# desc 检查备份 清理旧备份
result_file=/server/scripts/bak_result.txt
# 1 清理旧备份
find /backup -type f -name "*.tar.gz" -mtime +180 | xargs rm -f
# 2 统计备份结果
find /backup/ -type f -name "*.tar.gz" | xargs \
ls -lhd | \
awk -F'[ /]+' 'BEGIN{print "ip地址","备份文件","文件大小"} {print $(NF-1),$NF,$5}' | \
column -t > ${result_file}
# 2.5 检验md5
echo "以下信息为MD5校验的结果" >> ${result_file}
find /backup/ -name "fingerprint.md5" | xargs md5sum -c >> ${result_file}
# 3 发送邮件
mail -s "每日备份结果" qq@qq.com < ${result_file}
【Shell脚本】rsync服务端-备份数据检查
于 2024-08-12 16:05:22 首次发布