#!/bin/bash
dbs=`curl http://192.168.4.3:10088/config_server/get_db_config/all/name`
for db in $dbs
do
	sql_command=`curl http://192.168.4.3:10088/config_server/get_db_dump_command/${db}/opt`
  table_opt="mysqldump $sql_command --opt > /tmp/${db}_opt.sql"
	eval $table_opt
	mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}_opt.sql
	
		
	sql_tables=`curl http://192.168.4.3:10088/config_server/get_db_dump_command/${db}/table`
	if [[ sql_tables == '' ]];then
		echo "这个数据库没有基础数据需要同步"
	else
		table_data="mysqldump $sql_command --skip-lock-tables --tables  $sql_tables > /tmp/${db}_db.sql"
		eval $table_data
		
		mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}_db.sql
	fi
done