Merge "mariadb: Fixes incremental backup failure when full not created today"

This commit is contained in:
Zuul 2020-12-17 12:19:07 +00:00 committed by Gerrit Code Review
commit a8b6d26d27
3 changed files with 28 additions and 6 deletions

View File

@ -6,23 +6,31 @@ set -o pipefail
# Execute a full backup
backup_full() {
echo "Taking a full backup"
LAST_FULL_DATE=$(date +%d-%m-%Y)
mariabackup \
--defaults-file=/etc/mysql/my.cnf \
--backup \
--stream=xbstream \
--history=$(date +%d-%m-%Y) | gzip > \
--history=$LAST_FULL_DATE | gzip > \
$BACKUP_DIR/mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
echo $LAST_FULL_DATE > $BACKUP_DIR/last_full_date
}
# Execute an incremental backup
backup_incremental() {
echo "Taking an incremental backup"
if [ -r $BACKUP_DIR/last_full_date ]; then
LAST_FULL_DATE=$(cat $BACKUP_DIR/last_full_date)
fi
if [ -z $LAST_FULL_DATE ]; then
LAST_FULL_DATE=$(date +%d-%m-%Y)
fi
mariabackup \
--defaults-file=/etc/mysql/my.cnf \
--backup \
--stream=xbstream \
--incremental-history-name=$(date +%d-%m-%Y) \
--history=$(date +%d-%m-%Y) | gzip > \
--incremental-history-name=$LAST_FULL_DATE \
--history=$LAST_FULL_DATE | gzip > \
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
}

View File

@ -6,23 +6,31 @@ set -o pipefail
# Execute a full backup
backup_full() {
echo "Taking a full backup"
LAST_FULL_DATE=$(date +%d-%m-%Y)
mariabackup \
--defaults-file=/etc/mysql/my.cnf \
--backup \
--stream=xbstream \
--history=$(date +%d-%m-%Y) | gzip > \
--history=$LAST_FULL_DATE | gzip > \
$BACKUP_DIR/mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
echo $LAST_FULL_DATE > $BACKUP_DIR/last_full_date
}
# Execute an incremental backup
backup_incremental() {
echo "Taking an incremental backup"
if [ -r $BACKUP_DIR/last_full_date ]; then
LAST_FULL_DATE=$(cat $BACKUP_DIR/last_full_date)
fi
if [ -z $LAST_FULL_DATE ]; then
LAST_FULL_DATE=$(date +%d-%m-%Y)
fi
mariabackup \
--defaults-file=/etc/mysql/my.cnf \
--backup \
--stream=xbstream \
--incremental-history-name=$(date +%d-%m-%Y) \
--history=$(date +%d-%m-%Y) | gzip > \
--incremental-history-name=$LAST_FULL_DATE \
--history=$LAST_FULL_DATE | gzip > \
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
}

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes MariaDB incremental backup failure when full
backup was not created the same day.
`LP#1897948 <https://launchpad.net/bugs/1897948>`__