Commit b3157804 authored by tywldx's avatar tywldx

fix

parent 5ae7cc6c
......@@ -2,10 +2,19 @@
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}`
cmd="mysqldump $sql_command > /tmp/${db}.sql"
echo "$cmd"
eval $cmd
mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}.sql
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}.sql
fi
done
\ No newline at end of file
......@@ -58,9 +58,13 @@ module.exports = {
}
return this.dbs
},
get_mysql_dump_command:function(key){
get_mysql_dump_opt:function(key){
let item = this.dbs[key];
return `--host=${item.host} --port=${item.port} --user=${item.user} --password='${item.pwd}' ${key} --skip-lock-tables --tables ${item.sys_table_list}`
return `--host=${item.host} --port=${item.port} --user=${item.user} --password='${item.pwd}' ${key} `
}
get_mysql_dump_table:function(key){
let item = this.dbs[key];
return `${item.sys_table_list}`
},
get_target_mysql_command:function(key){
......
......@@ -91,8 +91,12 @@ admin.get('/get_db_config/:name/:attr', function (req, res) {
}
}
});
admin.get('/get_db_dump_command/:name', function (req, res) {
res.send(db_config.get_mysql_dump_command(req.params.name));
admin.get('/get_db_dump_command/:name/:opt', function (req, res) {
if(req.params.opt!="opt"){
res.send(db_config.get_mysql_dump_table(req.params.name));
}else{
res.send(db_config.get_mysql_dump_opt(req.params.name));
}
});
admin.get('/get_db_config/refersh',function(){
res.setHeader("Content-Type","application/json");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment