Skip to content

Commit b62f0f4

Browse files
committed
Fix: Recognize container that uses multiple DBs
Improvement: Allow backup of all databases
1 parent c6f2e59 commit b62f0f4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

init.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ echo
4747
# Display the container informations on standard out.
4848
#
4949

50-
CONTAINER=$(export | sed -nr "/ENV_MYSQL_DATABASE/{s/^.+ -x (.+)_ENV.+/\1/p;q}")
50+
CONTAINER=$(export | sed -nr "/ENV_MYSQL_ROOT_PASSWORD/{s/^.+ -x (.+)_ENV.+/\1/p;q}")
5151

5252
if [[ -z "${CONTAINER}" ]]
5353
then
@@ -86,7 +86,14 @@ umask ${UMASK}
8686
# Building common CLI options to use for mydumper and myloader.
8787
#
8888

89-
CLI_OPTIONS="-v 3 -h ${!DB_ADDR} -P ${!DB_PORT} -u root -p ${!DB_PASS} -B ${!DB_NAME} ${OPTIONS}"
89+
CLI_OPTIONS="-v 3 -h ${!DB_ADDR} -P ${!DB_PORT} -u root -p ${!DB_PASS} ${OPTIONS}"
90+
91+
if [ -z "${!DB_NAME}" ]; then
92+
echo "No DB_NAME available, backup all DBs"
93+
else
94+
CLI_OPTIONS="-B ${!DB_NAME} ${CLI_OPTIONS}"
95+
fi
96+
9097

9198
#
9299
# When MODE is set to "BACKUP", then mydumper has to be used to backup the database.

0 commit comments

Comments
 (0)