mysql---备份数据

#!/bin/bash

#owner:bi
#cronTime: 
#inputData:WORDBANK 
#describe:export data from WORDBANK to host 240 
#note:

source /etc/profile

ik_dir='/opt/cms_syc_seg/useDic/ik/stopword'
stoppool='/auto_cron/cron-running/dam/cy_ad_dat/stoppool'
ansj_dir='/opt/cms_syc_seg/useDic/ansj'
ik_dir_opt='/opt/bin/UDF/useDic/ik/stopword'

# export data in one file 
mysql  -h"10.***.3.***" -u"bi" -p'****' -Ne "set names utf8; SELECT wordname FROM WORDBANK.stop_relation_bank  WHERE flag=2" > ${ansj_dir}/stopword.txt

echo ${ansj_dir}/stopword.txt finished!

# export the name list to file
mysql  -h"10..3.2" -u"w" -p'****' -Ne "set names utf8; select distinct bankname from WORDBANK.wordbank where flag=0;"  > ${ik_dir}/'bankname.txt'

list=`cat ${ik_dir}/bankname.txt`

# loop
for i in $list;do

# create dir 
  if [ ! -d ${ik_dir}/$i ];then
  mkdir ${ik_dir}/${i}
  fi
  if [ ! -d ${stoppool}/$i ];then
  mkdir ${stoppool}/${i}
  fi
# export data in each file
mysql  -h"10..3.218" -u"w" -p'34' -Ne "set names utf8; select wordname from WORDBANK.stop_relation_bank where bankname='${i}' " > ${stoppool}/${i}/${i}.txt
cp ${stoppool}/${i}/${i}.txt ${ik_dir}/${i}.txt 
echo ${ik_dir}/${i}.txt ${stoppool}/${i}/${i}.txt finished!
# end loop
done

cp -r ${stoppool}/* ${ik_dir_opt}/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值