#!/bin/bash
Date=`date +%m%d%y -d "1 day ago"`
Date2=20`date +%y/%m/%d`-
Date3=`date +%H:%M:%S`
Date4=`date +%M`
mkdir /history/aa/$Date
touch /log/aa/$Date.log
echo "aa backup begin at $Date2$Date3" >> /log/aa/$Date.log
find /backup/aa/ -type f -mtime 1 -exec cp -av {} /history/aa/$Date/ \;
find /history/aa/ -type d -mtime 1 -empty -exec rmdir {} \;
Date5=20`date +%y/%m/%d`-
Date6=`date +%H:%M:%S`
Date7=`date +%M`
Date8=$(($Date7-$Date4))
echo "aa backup end at $Date5$Date6" >> /log/aa/$Date.log
echo "aa backup use time $Date8 minutes" >> /log/aa/$Date.log
/usr/bin/mail -s "aa backup done" aa@ming.com < /log/aa/$Date.log
不足:脚本需在0:00执行,否则24小时不能代表完整一天
本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1369867如需转载请自行联系原作者
yangzhimingg