Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-deploy-utils
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-deploy-utils
Commits
51427be6
Commit
51427be6
authored
Sep 04, 2017
by
daidekun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入对ip的正则判断,如果是完整ip,则不按最后一位取。
parent
adea5937
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
db_schema_sync.sh
db-utils/db_schema_sync.sh
+22
-3
No files found.
db-utils/db_schema_sync.sh
View file @
51427be6
...
...
@@ -27,8 +27,8 @@ source_db_host=$1
source_db_user
=
$2
source_db_pwd
=
'Uiwb@o^fR&nHOa5t'
ip_
last
=
$4
target_db_host
=
"192.168.4.
$ip_last
"
ip_
value
=
$4
target_db_user
=
$5
target_db_pwd
=
$6
...
...
@@ -41,6 +41,25 @@ work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder
=
~/db_sync_configs
db_backup_folder
=
~/db_backups
function
valid_ip
()
{
local
ip
=
$1
local stat
=
1
if
[[
$ip
=
~ ^[0-9]
{
1,3
}
\.
[
0-9]
{
1,3
}
\.
[
0-9]
{
1,3
}
\.
[
0-9]
{
1,3
}
$
]]
;
then
OIFS
=
$IFS
IFS
=
'.'
ip
=(
$ip
)
IFS
=
$OIFS
[[
${
ip
[0]
}
-le
255
&&
${
ip
[1]
}
-le
255
\
&&
${
ip
[2]
}
-le
255
&&
${
ip
[3]
}
-le
255
]]
stat
=
$?
fi
return
$stat
}
if
valid_ip
$ip_value
;
then
target_db_host
=
"
$ip_value
"
;
else
target_db_host
=
"192.168.4.
$ip_value
"
;
fi
function
db_schema_sync
()
{
database
=
$1
...
...
@@ -61,7 +80,7 @@ function db_schema_sync()
echo
"Step 2: replace domain name in tables:
$database
$mysql_host
$db_backup_sub_folders
"
echo
"Step 2.1: is re_replace_ip:
$re_replace_ip
"
sh
$work_dir
/db_replace_ip.sh
$database
$target_db_host
$db_backup_sub_folders
$re_replace_ip
$ip_
last
sh
$work_dir
/db_replace_ip.sh
$database
$target_db_host
$db_backup_sub_folders
$re_replace_ip
$ip_
value
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
$delete_business_data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment