#!/bin/bash
BIN_LOG_DIR="/data/mysql/data"
DATE=`date "+%Y%m%d"`
BAK_DIR="/data/dbbk/local"
BAK_PATH=$BAK_DIR/bin-log-bk/$DATE
REMOTE_IP=192.168.1.100
REMOTE_PATH=/dbbackup/wj_30/log/
REMOTE_PATH_1=/dbbackup/wj_30/err/
ERR_LOG_DIR=/data/mysql/data
BAK_PATH_1=$BAK_DIR/err
OUTDATE_FILE=`date -d '8 days ago' +%Y%m%d`
####
if [ ! -d $BAK_PATH ] ; then
  mkdir -p $BAK_PATH
fi
find $BIN_LOG_DIR -name "mysql-bin.*" -mmin -60 -exec cp -a '{}' $BAK_PATH ';';
#add by coco in 2012/09/27
if [ ! -d $BAK_PATH_1 ] ; then
  mkdir -p $BAK_PATH_1
fi
find $ERR_LOG_DIR -name "*error.log" -mmin -60 -type f | xargs grep "ERROR" >  $BAK_PATH_1/$DATE.err;
s=`du -b $BAK_PATH_1/$DATE.err|awk '{print $1}'`
if [ $s -gt 0 ] ; then
#if [ $BAK_PATH_1/$DATE.err -ne 0 ] ; then
echo ftp
#scp -r -p $BAK_PATH_1/$DATE.err root@$REMOTE_IP:$REMOTE_PATH_1
else
        rm -f $BAK_PATH_1/$DATE.err
fi
find $BAK_DIR/bin-log-bk -name "*" -mtime +10 |xargs rm -rf   删除本地10天前的日志文件
find $BAK_DIR -type d -empty |xargs rm -rf
####
ftp -n<