【Shell脚本】rsync服务端-备份数据检查

复制代码
#!/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}
相关推荐
运维行者_6 小时前
企业无线网络监控的挑战与智能化演进趋势
大数据·运维·服务器·网络·数据库
2603_955279707 小时前
Cursor + GitOps:自动化运维新姿势
运维·自动化
Waay7 小时前
面试口述版:个人对 Prometheus 完整理解
运维·学习·云原生·面试·职场和发展·kubernetes·prometheus
三8448 小时前
文件查找/文件压缩/解压缩
linux·运维·服务器
小猪写代码8 小时前
Linux 管道(Pipeline)作业
linux·运维·服务器
桌面运维家8 小时前
如何用半缓存云桌面将服务器硬盘容量扩展至本地终端?
运维·服务器·缓存
激情的学姐8 小时前
【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器
运维·nginx
ai_coder_ai9 小时前
编写自动化脚本,在自己后端服务中使用Open Api进行设备相关操作
java·运维·自动化
会周易的程序员10 小时前
microLog 的本地日志读取接口 log_reader — 本地日志文件读取工具开发指南
linux·物联网·架构·嵌入式·日志·iot·aiot
spider_xcxc10 小时前
Redis 数据库高质量实践指南(一)
运维·数据库·redis·oracle·云计算