#!/bin/sh
#backup-smslogs
day=`date +%Y-%m-%d`
log=/opt/smbss/smslogs/
cd $log
#1
if [ ! -e $day ]; then
mkdir $log/$day
elif [ -e $day ] && [ -f $day ]; then
rm -rf $log/$day
elif [ -e $day ] && [ -d $day ]; then
rm -rf $log/$day
mkdir $log/$day
fi
#2
if [ "$log" = "$PWD" ];then
mv *.sms $day
else
cd $log
mv *.sms $day
fi
#3
if [ -e $day ] && [ -d $day ]; then
tar -zcvf $day.sms.tar.gz $day
else
cd $log
tar -zcvf $day.sms.tar.gz $day
fi
#4
if [ "$?" = " " ]; then
mv $day.sms.tar.gz /disk/backup
else
cd $log
mv $day.sms.tar.gz /disk/backup
fi
#5
if [ -e $day ] && [ -d $day ]; then
mv $day /disk/data
else
cd $log
mv $day /disk/data
fi
if [ "$?" = "0" ] ;then
echo "success($day)"
else
echo "be defeated($day)"
fi
阅读(2220) | 评论(1) | 转发(0) |