mariadb: Fixes incremental backup failure when full not created today
backup_full() saves the history name in $BACKUP_DIR/last_full_date.
backup_incremental() attempts to read from $BACKUP_DIR/last_full_date
into $LAST_FULL_DATE. After the read attempt; if $LAST_FULL_DATE is zero
length then $(date +%d-%m-%Y) is used.
Change-Id: I4172b814d5d95ae3debbc1cf3feaeee2e2bec9bd
Closes-bug: 1897948
(cherry picked from commit ccfe65b5f7
)
This commit is contained in:
parent
ed85b40532
commit
b53a93faa3
|
@ -6,23 +6,31 @@ set -o pipefail
|
||||||
# Execute a full backup
|
# Execute a full backup
|
||||||
backup_full() {
|
backup_full() {
|
||||||
echo "Taking a full backup"
|
echo "Taking a full backup"
|
||||||
|
LAST_FULL_DATE=$(date +%d-%m-%Y)
|
||||||
mariabackup \
|
mariabackup \
|
||||||
--defaults-file=/etc/mysql/my.cnf \
|
--defaults-file=/etc/mysql/my.cnf \
|
||||||
--backup \
|
--backup \
|
||||||
--stream=xbstream \
|
--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
|
$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
|
# Execute an incremental backup
|
||||||
backup_incremental() {
|
backup_incremental() {
|
||||||
echo "Taking an incremental backup"
|
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 \
|
mariabackup \
|
||||||
--defaults-file=/etc/mysql/my.cnf \
|
--defaults-file=/etc/mysql/my.cnf \
|
||||||
--backup \
|
--backup \
|
||||||
--stream=xbstream \
|
--stream=xbstream \
|
||||||
--incremental-history-name=$(date +%d-%m-%Y) \
|
--incremental-history-name=$LAST_FULL_DATE \
|
||||||
--history=$(date +%d-%m-%Y) | gzip > \
|
--history=$LAST_FULL_DATE | gzip > \
|
||||||
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
|
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,23 +6,31 @@ set -o pipefail
|
||||||
# Execute a full backup
|
# Execute a full backup
|
||||||
backup_full() {
|
backup_full() {
|
||||||
echo "Taking a full backup"
|
echo "Taking a full backup"
|
||||||
|
LAST_FULL_DATE=$(date +%d-%m-%Y)
|
||||||
mariabackup \
|
mariabackup \
|
||||||
--defaults-file=/etc/mysql/my.cnf \
|
--defaults-file=/etc/mysql/my.cnf \
|
||||||
--backup \
|
--backup \
|
||||||
--stream=xbstream \
|
--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
|
$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
|
# Execute an incremental backup
|
||||||
backup_incremental() {
|
backup_incremental() {
|
||||||
echo "Taking an incremental backup"
|
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 \
|
mariabackup \
|
||||||
--defaults-file=/etc/mysql/my.cnf \
|
--defaults-file=/etc/mysql/my.cnf \
|
||||||
--backup \
|
--backup \
|
||||||
--stream=xbstream \
|
--stream=xbstream \
|
||||||
--incremental-history-name=$(date +%d-%m-%Y) \
|
--incremental-history-name=$LAST_FULL_DATE \
|
||||||
--history=$(date +%d-%m-%Y) | gzip > \
|
--history=$LAST_FULL_DATE | gzip > \
|
||||||
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
|
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>`__
|
Loading…
Reference in New Issue