Linux?μí3é?·?3£êμó?μ??¨?ú±?·Y??±?
?ò???úí???1¤×÷?D£?3£3£òa±?·Yò?D?×êá?£???è?ê??é2??′?ó£?μ?ê?oü·?ê±??μ?£??ò?ú?aà?·??íò???Linux±?·Y??±?£??á?é×?è?μ?êμ??×??ˉ±?·Y£?2¢?ò?éò? ±£á?Nìì±?·Yμ?μμ°??£?a????±?·??aá??????t£?ò???ê??′DD???tbackup.sh£?áíò???ê?±?·Y???????tproject.lst?£
backup.sh?à1??μ?÷
??òa2?êy?μ?÷
???t?úèY
#!/bin/bash
#author: InBi
#date: 2011-08-05
#role: backup files periodically.
#website: http://www.itwhy.org/2011/07-28/707.html
##################################################
LogFile=/backup/log/`date +"%Y-%m"`.log
SourceDir=/var/RDfile
BakDir=/backup
RetainDay=20
ProjectLst=/backup/project.lst
##################################################
DATE=`date +"%Y-%m-%d"`
echo "backup start at $(date +"%Y-%m-%d %H:%M:%S")" >$LogFile
echo "--------------------------------------------------" >>$LogFile
cd $BakDir
PROJECTLIST=`cat $ProjectLst`
for Project in $PROJECTLIST
do
ProjectData=$SourceDir/$Project
DestDir=$BakDir/$Project
PackFile=$DATE.$Project.tgz
if [ -f $BakDir/$PackFile ]
then
echo "backup file have exist !" >>$LogFile
else
cp -RHpf $ProjectData $DestDir >/dev/null
tar -zcvf $PackFile $Project >/dev/null
echo "backup $Project done into $PackFile" >>$LogFile
rm -rf $Project
fi
done
find $Bakdir -type f -mtime +$RetainDay -name "*.$Project.tgz" -exec rm {} \; >/dev/null
echo "--------------------------------------------------" >>$LogFile
echo "backup end at $(date +"%Y-%m-%d %H:%M:%S")" >>$LogFile
echo " " >> $LogFile
exit 0
相关新闻>>
- 发表评论
-
- 最新评论 更多>>