Skip to content

Commit dbaadc5

Browse files
committed
Added exit codes && users fix
Removed mysql create table && view dump patch
1 parent 4e8ae39 commit dbaadc5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

backup.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#!/bin/bash
22

3-
export -n $(egrep -v '^#' .env | xargs)
3+
export -n $(egrep -v '^#' $(dirname $0)/.env | xargs)
44

55

66
if [ -z "${BACKUP_DIR}" ]; then
77
echo "Empty Variable BACKUP_DIR"
8+
exit 1
89
fi
910

1011
if [ -z "${MYSQL_HOST}" ]; then
1112
echo "Empty Variable MYSQL_HOST"
13+
exit 1
1214
fi
1315

1416
if [ -z "${MYSQL_USER}" ]; then
1517
echo "Empty Variable MYSQL_USER"
18+
exit 1
1619
fi
1720

1821

@@ -60,6 +63,8 @@ VIEWS=$(echo -e "${VIEWS_LIST}" | tr ":!" "\n")
6063
for VIEW in $VIEWS; do # Concat ignore command
6164
VIEW_IGNORE_ARG="${VIEW_IGNORE_ARG} --ignore-table=${VIEW}"
6265
done
66+
# Replace ` in ${VIEW_IGNORE_ARG}, does not work with ` in table/database names
67+
VIEW_IGNORE_ARG=${VIEW_IGNORE_ARG//\`/}
6368
# echo -e "${VIEW_IGNORE_ARG}"
6469

6570
echo "Structure..."
@@ -69,7 +74,7 @@ echo "Data ..."
6974
mysqldump ${MYSQLDUMP_DEFAULTS} --routines=FALSE --triggers=FALSE --events=FALSE --no-create-info ${VIEW_IGNORE_ARG} --databases ${DBS} > ${BACKUP_DIR}/database.sql
7075

7176
echo "Users ..."
72-
mysqldump ${MYSQLDUMP_DEFAULTS} mysql --complete-insert --tables user db > ${BACKUP_DIR}/users.sql
77+
mysqldump ${MYSQLDUMP_DEFAULTS} mysql --no-create-info --complete-insert --tables user db > ${BACKUP_DIR}/users.sql
7378

7479
echo "Routines ..."
7580
mysqldump ${MYSQLDUMP_DEFAULTS} --routines=TRUE --triggers=FALSE --events=FALSE --no-create-info --no-data --no-create-db --databases ${DBS} > ${BACKUP_DIR}/routines.sql

0 commit comments

Comments
 (0)