Update backup.sh

added --single-transaction parameter to "halt" the mysql database while exporting
This commit is contained in:
Christian Hase 2021-04-07 19:19:42 +02:00 committed by GitHub
parent 4e5a9162f4
commit 9501648ce9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ do
echo "==> Dumping database: $db"
FILENAME=/backup/$DATE.$db.sql
LATEST=/backup/latest.$db.sql.gz
if mysqldump -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $db $MYSQLDUMP_OPTS > "$FILENAME"
if mysqldump --single-transaction -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $db $MYSQLDUMP_OPTS > "$FILENAME"
then
gzip "-$GZIP_LEVEL" -f "$FILENAME"
echo "==> Creating symlink to latest backup: $(basename "$FILENAME".gz)"