Commit 0e61e86f authored by QA-甘 盛聪's avatar QA-甘 盛聪

4.2commit2

parent 89bae323
......@@ -10,9 +10,18 @@
database_name=$1
mysql_host=$2
db_sub_backup_folder=$3
delete_business_data=$4
echo "cd $db_sub_backup_folder"
cd $db_sub_backup_folder
echo "delete_business_data:"$delete_business_data
if [ "$delete_business_data" = "true" ];then
echo "DROP DATABASE ${database_name};"
echo "DROP DATABASE ${database_name};" | mysql -h $mysql_host -uqa -pqatest
echo "CREATE DATABASE IF NOT EXISTS \`${database_name}\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
echo "CREATE DATABASE IF NOT EXISTS \`${database_name}\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;" | mysql -h $mysql_host -uqa -pqatest
fi
for entry in ./*
do
......
......@@ -10,11 +10,12 @@
source ~/.bash_profile
source ~/.profile
if [ $# -ne 8 ]; then
if [ $# -ne 9 ]; then
echo "---------------"
echo "source_db_infos:source_db_host: $1, source_db_user: $2"
echo "target_db_infos:target_db_host: $4, target_db_user: $5"
echo "sync_db_name: $7, re_replace_ip: $8"
echo "delete_business_data: $9"
echo "---参数不正确---"
echo "Usage:sh db_schema_sync.sh source_db_host source_db_user source_db_pwd target_db_host target_db_user target_db_pwd sync_db_name"
echo "---------------"
......@@ -32,6 +33,7 @@ target_db_pwd=$6
sync_db_name=$7
re_replace_ip=$8
delete_business_data=$9
work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs
......@@ -51,6 +53,7 @@ function db_schema_sync()
echo "source infos: $source_db_host $source_db_user"
echo "target infos: $target_db_host $target_db_user"
echo "database_name is : $sync_db_name"
echo "delete_business_data : $delete_business_data"
sh $work_dir/db_gen_config.sh $source_db_host $source_db_user $source_db_pwd $target_db_host $target_db_user $target_db_pwd $database $config_file_name $db_backup_sub_folders
......@@ -59,7 +62,7 @@ function db_schema_sync()
sh $work_dir/db_replace_ip.sh $database $target_db_host $db_backup_sub_folders $re_replace_ip $ip_last
echo "Step 3: import basic data from backup file: $database $mysql_host $db_backup_sub_folders"
sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders
sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders $delete_business_data
echo "Step 4: sync schema: $database $target_db_host"
sync_cmd="mss -conf ${config_file_name} -sync"
......
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