Merge "Stein: support mariabackup for backups" into stable/stein

This commit is contained in:
Zuul 2019-11-07 09:48:39 +00:00 committed by Gerrit Code Review
commit 2692fec709
2 changed files with 51 additions and 0 deletions

View File

@ -52,6 +52,9 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start \
RUN mkdir -p /var/run/mysqld && chown mysql /var/run/mysqld && chmod 755 /var/run/mysqld
{% endif %}
COPY backup.sh /usr/local/bin/kolla_mariadb_backup.sh
RUN chmod 755 /usr/local/bin/kolla_mariadb_backup.sh
{% if use_dumb_init %}
{% block mariadb_entrypoint %}
# NOTE(mgoddard): Override the dumb-init arguments to avoid passing

48
docker/mariadb/backup.sh Normal file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -eu
set -o pipefail
# Execute a full backup
backup_full() {
echo "Taking a full backup"
mariabackup \
--defaults-file=/etc/mysql/my.cnf \
--backup \
--stream=xbstream \
--history=$(date +%d-%m-%Y) | gzip > \
$BACKUP_DIR/mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
}
# Execute an incremental backup
backup_incremental() {
echo "Taking an incremental backup"
mariabackup \
--defaults-file=/etc/mysql/my.cnf \
--backup \
--stream=xbstream \
--incremental-history-name=$(date +%d-%m-%Y) \
--history=$(date +%d-%m-%Y) | gzip > \
$BACKUP_DIR/incremental-$(date +%H)-mysqlbackup-$(date +%d-%m-%Y-%s).qp.xbc.xbs.gz
}
BACKUP_DIR=/backup/
cd $BACKUP_DIR
if [ -n $BACKUP_TYPE ]; then
case $BACKUP_TYPE in
"full")
backup_full
;;
"incremental")
backup_incremental
;;
*)
echo "Only full or incremental options are supported."
exit 1
;;
esac
else
echo "You need to specify either full or incremental backup options."
exit 1
fi