#如果备份目录大小超过限制,删除部分日志
Sizeoflog=0
Sizeoflog=`du -k ${RealBaseLogBakPath} |grep -v "$RealBaseLogBakPath/" |awk '{printf "%s\n",$1}'`
if [ ${Sizeoflog} -gt ${MaxBakDirSize} ];then
$mhome/bin/dellogdir ${BakThirdDirName} ${willrmdays}
Result=$?
if [ ${Result} -eq 1 ]
then
echo "删除${RealBaseLogBakPath}/${BakDirName}/${BakThirdDirName}\n\n" >> ${BakLogFileName}
rm -rf ${RealBaseLogBakPath}/${BakDirName}/${BakThirdDirName}
else
#如果相差的天数是在${willorigdays}与${willrmdays}之间的话,就压缩该目录,并删除原始日志
$mhome/bin/dellogdir ${BakThirdDirName} ${willorigdays}
Result=$?
if [ ${Result} -eq 1 ];then
echo "压缩并删除${RealBaseLogBakPath}/${BakDirName}/${BakThirdDirName}目录\n\n" >> ${BakLogFileName}
tar -cf - ${RealBaseLogBakPath}/${BakDirName}/${BakThirdDirName} | gzip > ${RealBaseLogBakPath}/${BakDirName}/${BakThirdDirName}.tar.gz
rm -rf ${RealBaseLogBakPath}/${BakDirName}/${BakThirdDirName}
fi
fi
分享到:
评论