Skip to content

Commit 624ecf5

Browse files
committed
Fix GRANT list dump
1 parent 20434e1 commit 624ecf5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

backup.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,14 @@ if [ "$?" -eq 0 ]; then
255255
if [ "$?" -ne 0 ]; then
256256
exitWithMsg 214 "Grants dump failed"
257257
fi
258-
echo ${GRANTS_LIST} | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 --/;/--/{x;p;x;}' > ${BACKUP_DIR}/grants.sql
259-
258+
printf "%s\n" "${GRANTS_LIST}" > ${BACKUP_DIR}/grants.sql
259+
# Replace headers to the SQL comment format
260+
sed -i -E "s/^Grants for (.*)/-- Grants for \1/" ${BACKUP_DIR}/grants.sql
261+
# Add a ; at each line end
262+
sed -i -E '/^-- Grants for/! s/^(.*)$/\1;/' ${BACKUP_DIR}/grants.sql
260263

261264
# Removes double backslashes > \\
262265
sed -i -e 's/\\\\//g' ${BACKUP_DIR}/grants.sql
263-
# echo -e ${GRANTS_SQL}
264266
fi
265267

266268

0 commit comments

Comments
 (0)