#! /bin/bash
basedir="/data/web/"
bakdir="/data/web_backup"
while :; do
cd $basedir
sum=0
for f in `ls|grep -v logs|grep -v tmp `; do
n=`find $f/ -type f -mmin -5 |wc -l`
sum=$[$sum+$n]
done
prename=`date +%m%d%H%M`
if [ $sum -gt "0" ]; then
/usr/bin/rsync -a --exclude=logs --exclude=tmp $basedir $bakdir/$prename\_web
cd $bakdir
tar zcf $prename\_web.tar.gz $prename\_web
rm -r $prename\_web
/usr/bin/find $bakdir/ -mtime +2 |xargs rm -rf
fi
sleep 300
done