discuz论坛附件递增备份脚本

#! /bin/bash
exec 1>/var/log/serverattbak.log 2>&1
soudir=web:/home/www/attachments
bakdir=/attachments/attbak/serverbak
d=`date --date "-1 day" +%y%m%d`
d2=`date  +%y%m%d`
w=`date +%w`
rs=/usr/bin/rsync
echo serverbak begin at `date`
[ -d $bakdir/server-$w ] || mkdir $bakdir/server-$w
if [ $w = "0" ]; then

        $rs -ar --delete $soudir/* $bakdir/server-$w/
else
        $rs -ar $soudir/day_$d/  $bakdir/server-$w/day_$d/
        $rs -ar $soudir/day_$d2/  $bakdir/server-$w/day_$d2/
        /usr/bin/find $bakdir/server-$w/ -type f -mmin +1600 |xargs rm -f
fi
echo serverbak end at `date`

添加新评论 »