#!/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`
Name1=`date +%m`
Name2=`date +%d -d "1 day ago"`
Num2=`echo -$Name2`
Name3=`date +%y`
Num3=`echo -20$Name3`
Num4=`echo $Name1$Num2$Num3`
sudo touch /log/aa/$Date.log
sudo echo "aa backup begin at $Date2$Date3" >> /log/aa/$Date.log
sudo find /backup/aa/ -type d -name $Num4 -exec cp -av {} /history/aa/ \;
Date5=20`date +%y/%m/%d`-
Date6=`date +%H:%M:%S`
Date7=`date +%M`
Date8=$(($Date7-$Date4))
sudo echo "aa backup end at $Date5$Date6" >> /log/aa/$Date.log
sudo 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
本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1369866如需转载请自行联系原作者
yangzhimingg