Skip to content

Commit d46edaf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "mariadb: Fixes incremental backup failure when full not created today" into stable/victoria
2 parents 2cf83cc + 2d18e19 commit d46edaf

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

docker/mariadb/mariadb-server/backup.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,31 @@ set -o pipefail
66
# Execute a full backup
77
backup_full() {
88
echo "Taking a full backup"
9+
LAST_FULL_DATE=$(date +%d-%m-%Y)
910
mariabackup \
1011
--defaults-file=/etc/mysql/my.cnf \
1112
--backup \
1213
--stream=xbstream \
13-
--history=$(date +%d-%m-%Y) | gzip > \
14+
--history=$LAST_FULL_DATE | gzip > \
1415
$BACKUP_DIR/mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
16+
echo $LAST_FULL_DATE > $BACKUP_DIR/last_full_date
1517
}
1618

1719
# Execute an incremental backup
1820
backup_incremental() {
1921
echo "Taking an incremental backup"
22+
if [ -r $BACKUP_DIR/last_full_date ]; then
23+
LAST_FULL_DATE=$(cat $BACKUP_DIR/last_full_date)
24+
fi
25+
if [ -z $LAST_FULL_DATE ]; then
26+
LAST_FULL_DATE=$(date +%d-%m-%Y)
27+
fi
2028
mariabackup \
2129
--defaults-file=/etc/mysql/my.cnf \
2230
--backup \
2331
--stream=xbstream \
24-
--incremental-history-name=$(date +%d-%m-%Y) \
25-
--history=$(date +%d-%m-%Y) | gzip > \
32+
--incremental-history-name=$LAST_FULL_DATE \
33+
--history=$LAST_FULL_DATE | gzip > \
2634
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
2735
}
2836

docker/mariadb/mariadb/backup.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,31 @@ set -o pipefail
66
# Execute a full backup
77
backup_full() {
88
echo "Taking a full backup"
9+
LAST_FULL_DATE=$(date +%d-%m-%Y)
910
mariabackup \
1011
--defaults-file=/etc/mysql/my.cnf \
1112
--backup \
1213
--stream=xbstream \
13-
--history=$(date +%d-%m-%Y) | gzip > \
14+
--history=$LAST_FULL_DATE | gzip > \
1415
$BACKUP_DIR/mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
16+
echo $LAST_FULL_DATE > $BACKUP_DIR/last_full_date
1517
}
1618

1719
# Execute an incremental backup
1820
backup_incremental() {
1921
echo "Taking an incremental backup"
22+
if [ -r $BACKUP_DIR/last_full_date ]; then
23+
LAST_FULL_DATE=$(cat $BACKUP_DIR/last_full_date)
24+
fi
25+
if [ -z $LAST_FULL_DATE ]; then
26+
LAST_FULL_DATE=$(date +%d-%m-%Y)
27+
fi
2028
mariabackup \
2129
--defaults-file=/etc/mysql/my.cnf \
2230
--backup \
2331
--stream=xbstream \
24-
--incremental-history-name=$(date +%d-%m-%Y) \
25-
--history=$(date +%d-%m-%Y) | gzip > \
32+
--incremental-history-name=$LAST_FULL_DATE \
33+
--history=$LAST_FULL_DATE | gzip > \
2634
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
2735
}
2836

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes MariaDB incremental backup failure when full
5+
backup was not created the same day.
6+
`LP#1897948 <https://launchpad.net/bugs/1897948>`__

0 commit comments

Comments
 (0)