#!/bin/bash
Date=`date +%m%d%y -d "-1 day"`

Date2=20`date +%y/%m/%d`-

Date3=`date +%H:%M:%S`

Date4=`date +%M`

Name1=`date +%m`
Name2=`date +%d -d "1 day ago"`*
Name3=STHR_db_20`date +%y`
Name4=$Name3$Name1$Name2
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 -name $Name4 -exec cp -av {} /history/aa/$Date/ \;

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


注:

-type f指文件类似为文件 d为目录

-name 指文件名为

cp -a 拷贝时不改变文件的时间戳