server端脚本
1 #!/bin/bash 2 #1 进行数据完整性验证 并生成结果 3 find /backup -type f -name "finger.txt"| xargs md5sum -c &>/tmp/check_info.txt 4 5 #02 实现发送邮件功能 6 mail -s "check_info" [email protected] </tmp/check_info.txt 7 8 #03 保存180天的数据 9 find /backup -type f -name "*.tar.gz" -mtime +180 -not -name "*_week1.tar.gz" | xargs rm -f
client端
1 #/bin/bash 2 backup_dir="/backup" 3 date_info=$(date +%F_week%w -d -1day) 4 ip_info=$(hostname -i) 5 #1 6 mkdir $backup_dir/$ip_info/ /var/html/www /app/logs -p 7 8 #2 9 cd / 10 11 tar zchf $backup_dir/$ip_info/bak_$date_info.tar.gz ./var/spool/cron/root ./etc/rc.local ./server/scripts ./etc/sysconfig/iptables 12 tar zchf $backup_dir/$ip_info/www-bak_$date_info.tar.gz ./var/html/www 13 tar zchf $backup_dir/$ip_info/log-bak_$date_info.tar.gz ./app/logs 14 15 #生成指纹信息 16 find $backup_dir/$ip_info/ -type f -name "*_$date_info.tar.gz"|xargs md5sum >>$backup_dir/$ip_info/finger.txt 17 #3.3 18 rsync -az $backup_dir/ [email protected]::backup --password-file=/etc/rsync.password 19 #4 20 find $backup_dir/ -type f -name "*.tar.gz" -mtime +7| xargs rm -f