#!/bin/bash source ~/.bashrc
db='bfb_db_finance' #tables=('t_rate_configure') tables=('t_rate_configure' 't_cnt_for_cal_fee' 't_bank_rate_modify_log' 't_reserve_bank_account' 't_reserve_bank_account_channel' 't_reserve_bank_account_channel_ details' 't_reserve_bank_account_channel_files' 't_reserve_bank_account_channel_log' 't_outercheck_summary' 't_holiday_dates') export_dir=~/tmp/script/data
echo 'start to export from fndb online...' fndb_mine -e "create database if not exists bfb_db_finance;" for tab in ${tables[@]}; do fndb_online -N -e "select * from ${db}.${tab}" > $export_dir"/"$tab & create_sql=`fndb_online -N -e "show create table ${db}.${tab}"` len=${#tab} create_sql=${create_sql:$len} echo -e "$create_sql" > $export_dir"/create_"$tab & done; wait echo 'finished to export from fndb online.' echo 'start to import to fndb offline...' for tab in ${tables[@]}; do fndb_mine -e "drop table if exists ${db} . ${tab}" create_sql=`cat ${export_dir}/create_${tab}` fndb_mine -e "use ${db}; $create_sql" fndb_mine -N -e "truncate ${db} . ${tab}; LOAD DATA LOCAL INFILE '$export_dir/$tab' INTO TABLE ${db} . ${tab}" wait echo ${tab}" done." rm $export_dir"/"$tab & rm $export_dir/"create_"$tab & done; echo 'done.'