MariaDB backup workflow¶
The OpenStack database backup workflow includes the following phases:
Backup phase 1:
The
mariadb-phy-backup
job launches themariadb-phy-backup-<TIMESTAMP>
pod. This pod contains the main backup script, which is responsible for:Basic sanity checks and choosing right node for backup
Verifying the wsrep status and changing the
wsrep_desync
parameter settingsManaging the
mariadb-phy-backup-runner
pod
During the first backup phase, the following actions take place:
Sanity check: verification of the Kubernetes status and wsrep status of each MariaDB pod. If some pods have wrong statuses, the backup job fails unless the
--allow-unsafe-backup
parameter is passed to the main script in the Kubernetes backup job.Note
Mirantis does not recommend setting the
--allow-unsafe-backup
parameter unless it is absolutely required. To ensure the consistency of a backup, verify that the MariaDB galera cluster is in a working state before you proceed with the backup.Select the replica to back up. The system selects the replica with the highest number in its name as a target replica. For example, if the MariaDB server pods have the
mariadb-server-0
,mariadb-server-1
, andmariadb-server-2
names, themariadb-server-2
replica will be backed up.Desynchronize the replica from the Galera cluster. The script connects the target replica and sets the
wsrep_desync
variable toON
. Then, the replica stops receiving write-sets and receives the wsrep statusDonor/Desynced
. The Kubernetes health check of thatmariadb-server
pod fails and the Kubernetes status of that pod becomesNot ready
. If the pod has theprimary
label, the MariaDB controller sets thebackup
label to it and the pod is removed from the endpoints list of the MariaDB service.
Backup phase 2:
The main script in the
mariadb-phy-backup
pod launches the Kubernetes podmariadb-phy-backup-runner-<TIMESTAMP>
on the same node where the targetmariadb-server
replica is running, which is nodeX
in the example.The
mariadb-phy-backup-runner
pod has bothmysql
data directory andbackup
directory mounted. The pod performs the following actions:Verifies that there is enough space in the
/var/backup
folder to perform the backup. The amount of available space in the folder should be greater than<DB-SIZE> * <MARIADB-BACKUP-REQUIRED-SPACE-RATIO
in KB.Performs the actual backup using the mariabackup tool.
If the number of current backups is greater than the value of the
MARIADB_BACKUPS_TO_KEEP
job parameter, the script removes all old backups exceeding the allowed number of backups.Exits with
0
code.
The script waits untill the
mariadb-phy-backup-runner
pod is completed and collects its logs.The script puts the backed up replica back to sync with the Galera cluster by setting
wsrep_desync
toOFF
and waits for the replica to becomeReady
in Kubernetes.