#!/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://172.29.1.15:10088/config_server/get_db_dump_command/${db}/opt`
  table_opt="mysqldump --opt $sql_command > /tmp/${db}_opt.sql"
	echo "$table_opt"
	eval $table_opt
	mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}_opt.sql
	
		
	sql_tables=`curl http://172.29.1.15: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 --skip-add-locks --no-create-info --complete-insert > /tmp/${db}_db.sql"
		echo "$table_data"
		eval $table_data
		
		mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}_db.sql
	fi
done