toxic

备忘录

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#!/bin/bash

today=`date +%Y%m%d`
dbbak_path=/opt/dbbak
script_path=/opt/script
dbfiles_path=/opt/dbbak/dbfiles
data_path=/opt/svr/mysql/data

#备份数据文件
if [ -d $dbfiles_path/$today ];then 
  echo 'warnning:目录已经存在'
else   
  /bin/mkdir $dbfiles_path/$today
fi

/bin/cp -r $data_path/027game $dbfiles_path/$today/027game
/bin/cp -r $data_path/027game_bbs $dbfiles_path/$today/027game_bbs
/bin/cp -r $data_path/ad_flow $dbfiles_path/$today/ad_flow

if [ $? -ne 0 ];then 
   echo "备份数据文件错误-------------`date`" >> $script_path/ad.log
   exit 1
fi

#统计数据
/opt/svr/mysql/bin/mysql -uroot -p12341234!@ 027game < $script_path/caculate.sql

if [ $? -ne 0 ];then 
  echo "统计程序出错---------`date`" >> $script_path/ad.log
  exit 1
fi


#清理之前先备份数据
backup_sql_filename="$today.sql"
/opt/svr/mysql/bin/mysqldump -uroot -p12341234!@ ad_flow > $dbbak_path/ad_flow/$backup_sql_filename

if [ $? -ne 0 ];then
  echo "备份程序出错-----`date`" >> $script_path/ad.log
  exit 1
fi

#清理广告点击,注册,ip
/opt/svr/mysql/bin/mysql -uroot -p12341234!@ ad_flow < $script_path/clear_ad.sql

if [ $? -ne 0 ];then 
echo "清理广告数据出现错误---`date`" >> $script_path/ad.log
exit 1
fi

exit 0
posted on 2012-10-31 17:48  toxic  阅读(218)  评论(0编辑  收藏  举报