Create the GaleraBackup CR

To create backups of each Galera database instance, you create a GaleraBackup CR that defines the backup schedule and retention for the MariaDB database clusters.

Schedule database backups

Create a GaleraBackup CR for each MariaDB Galera database instance that you want to backup. The resource creates a cronjob that defines the backup schedule for the database instance, a PVC, and the associated RBAC resources for retention of the database instance.

Procedure

  1. Create a GaleraBackup CR file for the Galera database instance named galera-backup.yaml:
    apiVersion: mariadb.openstack.org/v1beta1
    kind: GaleraBackup
    metadata:
      name: openstackbackup
      namespace: openstack
    spec:
      databaseInstance: openstack
    • databaseInstance: The name of the MariaDB Galera database instance. If you create a GaleraBackup CR that only specifies the name of the database instance, then the storage class, size, and schedule are all inherited from the Galera CR for that database instance.
  2. Optional: Customize the backup schedule:
    spec:
      databaseInstance: openstack
      schedule: <cron_schedule>

    where:

    <cron_schedule>

    Specifies the backup schedule for the database instance, for example:

    • "@daily" performs the backup at midnight every day
    • "30 2 * * 0" performs the backup on Sundays at 02:30
    • "0 */6 * * *" performs the backup every 6 hours

    If not configured, the GaleraBackup CR configures a cronJob to perform daily backups by default.

  3. Configure the retention period for backups:
    spec:
      ...
      retention: <duration>

    where:

    <duration>
    Specifies how long to retain the backups in hours, for example, 72h deletes backups older than 3 days. The backup job automatically deletes backup files for the database instance that are older than this retention period at the end of each run. If not configured, backup files accumulate on the PVC indefinitely.
  4. Create the GaleraBackup CR:
    $ oc apply -f galera-backup.yaml
  5. Wait for the GaleraBackup CR to be ready:
    $ oc wait --for=condition=Ready galerabackup/openstackbackup

Manage PVCs for GaleraBackup CRs

To separate your final SQL dumps from intermediate binary data, configure a dedicated transfer volume for your volume-level snapshots.

About this task

By default, the GaleraBackup custom resource (CR) uses a single persistent volume claim (PVC) for both the intermediate binary data for the State Snapshot Transfer (SST) snapshot and the final SQL dumps. If you rely on volume-level backups in addition to using the GaleraBackup CR, only the SQL dump files must be captured in the CSI snapshots. The binary data transferred over SST is transient and does not need to be snapshotted.

Note

If you delete a GaleraBackup CR the associated PVCs are not automatically deleted to preserve the backed up data. If you no longer need to preserve the backup PVCs, use the following command to delete them:

$ oc delete pvc <pvc_name>

Procedure

  1. Open your GaleraBackup CR file on your workstation.
  2. Configure a dedicated transfer volume for the SQL dump files:
    apiVersion: mariadb.openstack.org/v1beta1
    kind: GaleraBackup
    metadata:
      name: openstackbackup
    spec:
      databaseInstance: openstack
      transferStorage:
        storageRequest: <storage_size>

    where:

    <storage_size>
    Specifies the size of the PVC in binary units, for example, 400Mi.
  3. Update the GaleraBackup CR:
    $ oc apply -f galera-backup.yaml
  4. Wait for the GaleraBackup CR to be ready:
    $ oc wait --for=condition=Ready galerabackup/openstackbackup
  5. List the PVCs in the /backup/data directory to confirm that the distinct PVCs have been created:
    • mysql-backup-openstackbackup: Contains the SQL dumps.
    • mysql-transfer-openstackbackup: Contains the transient SST data.