Enable OpenStack database periodic backups¶
A MOSK cluster includes a built-in automated mechanism to
back up an OpenStack database. The mechanism is implemented as a Kubernetes
cron job named mariadb-phy-backup
. By default, the job is suspended.
Note
If you are using the default back end to store the backup data, which is Ceph, you can increase the default size of a backup volume. However, make sure that you configure the volume size before OpenStack deployment is complete.
For the default sizes and configuration details, refer to Size of a backup storage.
To enable the OpenStack databases backup:
Enable the backup in the
OpenStackDeployment
object:spec: features: database: backup: enabled: true
Verify that the
mariadb-phy-backup
CronJob object is present:kubectl -n openstack get cronjob mariadb-phy-backup
Example of a
mariadb-phy-backup
CronJob objectapiVersion: batch/v1beta1 kind: CronJob metadata: annotations: openstackhelm.openstack.org/release_uuid: "" creationTimestamp: "2020-09-08T14:13:48Z" managedFields: <<<skipped>>>> name: mariadb-phy-backup namespace: openstack resourceVersion: "726449" selfLink: /apis/batch/v1beta1/namespaces/openstack/cronjobs/mariadb-phy-backup uid: 88c9be21-a160-4de1-afcf-0853697dd1a1 spec: concurrencyPolicy: Forbid failedJobsHistoryLimit: 1 jobTemplate: metadata: creationTimestamp: null labels: application: mariadb-phy-backup component: backup release_group: openstack-mariadb spec: activeDeadlineSeconds: 4200 backoffLimit: 0 completions: 1 parallelism: 1 template: metadata: creationTimestamp: null labels: application: mariadb-phy-backup component: backup release_group: openstack-mariadb spec: containers: - command: - /tmp/mariadb_resque.py - backup - --backup-timeout - "3600" - --backup-type - incremental env: - name: MARIADB_BACKUPS_TO_KEEP value: "10" - name: MARIADB_BACKUP_PVC_NAME value: mariadb-phy-backup-data - name: MARIADB_FULL_BACKUP_CYCLE value: "604800" - name: MARIADB_REPLICAS value: "3" - name: MARIADB_BACKUP_REQUIRED_SPACE_RATIO value: "1.2" - name: MARIADB_RESQUE_RUNNER_IMAGE value: docker-dev-kaas-local.docker.mirantis.net/general/mariadb:10.4.14-bionic-20200812025059 - name: MARIADB_RESQUE_RUNNER_SERVICE_ACCOUNT value: mariadb-phy-backup-runner - name: MARIADB_RESQUE_RUNNER_POD_NAME_PREFIX value: openstack-mariadb - name: MARIADB_POD_NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace image: docker-dev-kaas-local.docker.mirantis.net/general/mariadb:10.4.14-bionic-20200812025059 imagePullPolicy: IfNotPresent name: phy-backup resources: {} securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /tmp name: pod-tmp - mountPath: /tmp/mariadb_resque.py name: mariadb-bin readOnly: true subPath: mariadb_resque.py - mountPath: /tmp/resque_runner.yaml.j2 name: mariadb-bin readOnly: true subPath: resque_runner.yaml.j2 - mountPath: /etc/mysql/admin_user.cnf name: mariadb-secrets readOnly: true subPath: admin_user.cnf dnsPolicy: ClusterFirst initContainers: - command: - kubernetes-entrypoint env: - name: POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - name: NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace - name: INTERFACE_NAME value: eth0 - name: PATH value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/ - name: DEPENDENCY_SERVICE - name: DEPENDENCY_DAEMONSET - name: DEPENDENCY_CONTAINER - name: DEPENDENCY_POD_JSON - name: DEPENDENCY_CUSTOM_RESOURCE image: docker-dev-kaas-local.docker.mirantis.net/openstack/extra/kubernetes-entrypoint:v1.0.0-20200311160233 imagePullPolicy: IfNotPresent name: init resources: {} securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true runAsUser: 65534 terminationMessagePath: /dev/termination-log terminationMessagePolicy: File nodeSelector: openstack-control-plane: enabled restartPolicy: Never schedulerName: default-scheduler securityContext: runAsUser: 999 serviceAccount: mariadb-phy-backup serviceAccountName: mariadb-phy-backup terminationGracePeriodSeconds: 30 volumes: - emptyDir: {} name: pod-tmp - name: mariadb-secrets secret: defaultMode: 292 secretName: mariadb-secrets - configMap: defaultMode: 365 name: mariadb-bin name: mariadb-bin schedule: 0 1 * * * successfulJobsHistoryLimit: 3 suspend: false
If required, adjust the periodic backup job configuration. By default, the backup is set up as follows:
Runs on a daily basis at 01:00 AM
Creates incremental backups daily and full backups weekly
Keeps 10 latest full backups
Saves backups to the
mariadb-phy-backup-data
PVCThe backup timeout is
3600
secondsThe backup type is
incremental
As illustrated in the cron job example, the
mariadb_resque.py
script launches backups of the MariaDB Galera cluster. The script accepts settings through parameters and environment variables. See the configuration details in the Reference Arhitecture: Configuring a periodic backup.