Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
gitlab-com
migration
Commits
1a52a157
Commit
1a52a157
authored
Aug 06, 2018
by
Matteo Melli
Browse files
Added logs with timestamps
parent
c42e037b
Pipeline
#88718
failed with stage
in 16 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
5 deletions
+33
-5
.gitignore
.gitignore
+2
-1
bin/migration
bin/migration
+1
-0
bin/utilities
bin/utilities
+30
-4
No files found.
.gitignore
View file @
1a52a157
source_vars
.project
\ No newline at end of file
.project
migration.log
\ No newline at end of file
bin/migration
View file @
1a52a157
#!/bin/bash
set
-eu
[[
$#
-lt
2
]]
&&
{
echo
"Specify the environment and role"
;
exit
1
;
}
...
...
bin/utilities
View file @
1a52a157
...
...
@@ -2,8 +2,15 @@
function
do_step
(){
echo
"Executing:
$@
"
"
$@
"
||
{
echo
"Step
`
$@
`
Failed."
;
exit
2
;
}
\
&&
echo
"Step
`
$@
`
ran OK"
echo
if
"
$@
"
then
echo
echo
"==================== Step
$@
ran OK ===================="
else
echo
>
&2
echo
"!!!!!!!!!!!!!!!!!!!!! Step
$@
Failed !!!!!!!!!!!!!!!!!!!!!"
fi
}
...
...
@@ -53,10 +60,26 @@ function step_check(){
fi
}
function
next_step
(){
printf
"%03d"
"
$((
$(
step_number
"
$1
"
)
+
1
))
"
}
function
prepend_timestamp
(){
while
IFS
=
read
-r
line
;
do
printf
'[%s] %s\n'
"
$(
date
'+%Y-%m-%d %H:%M:%S'
)
"
"
$line
"
;
done
}
function
do_menu
(){
next_step
=
"
$(
step_3digit_number
"
${
steps
[0]
}
"
)
"
while
true
do
echo
"Environment:"
echo
"Azure master:
$AZURE_MASTER
"
echo
"Azure slaves:
${
AZURE_SLAVES
[*]
}
"
echo
"Azure pgbouncers:
${
AZURE_PGBOUNCERS
[*]
}
"
echo
"GCP master candidate:
$GCP_MASTER_CANDIDATE
"
echo
"GCP slaves:
${
GCP_SLAVES
[*]
}
"
echo
"GCP pgbouncers:
${
GCP_PGBOUNCERS
[*]
}
"
echo
echo
"Available steps:"
echo
for
step
in
"
${
steps
[@]
}
"
...
...
@@ -127,10 +150,13 @@ function do_menu(){
fi
echo
read
-r
-s
-N
1
-p
"Press [y] to continue, any other key to abort."
key
echo
if
[
"
$key
"
==
"y"
]
then
next_step
=
"
$(
printf
"%03d"
"
$((
$(
step_number
"
$step
"
)
+
1
))
"
)
"
do_step
"
$script
"
next_step
=
"
$(
next_step
"
$step
"
)
"
do_step
"
$script
"
>
>(
prepend_timestamp |
tee
-a
migration.log
)
2>
>(
prepend_timestamp |
tee
-a
migration.log
>
&2
)
# wait for the redirect subshells to complete
sleep
1
fi
echo
step
=
...
...
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