For AI agents: this documentation is indexed for you in llms.txt, and all of it in /llms.txt. Every page is also available as markdown: append .md to its address.

Back up and restore

This guide describes how to use the DBBackup Custom Resource to:

Perform a backup of a database

This section describes how you can prepare backups of your database deployed using the Cennso Database Instance.

Important

The backup job runs against a read replica instead of the primary, so the target DBInstance must run at least one read replica, with spec.mysql.size set to 2 or more. If the cluster runs only a single instance, the backup job cannot find a pod to back up and fails with the error: ERROR: No read replica found. Backup can be performed only on a read replica.. For more information, see the Configuration restrictions section.

To deploy a Cennso Database Backup, execute the following steps:

  1. Prepare the Kubernetes secret in the Kubernetes namespace where your MySQL cluster is up and running. This secret should contain the list of environment variables with the data needed for the authorisation at a ResticOpens in a new tab backend. To prepare a secret, create a file, for example secret.data, with the list of environment variables which you need to authorise at a restic backend. For example:

    bash

    Note

    To find information about all supported environment variables, see the official documentationOpens in a new tab.

    At the next step, encode the contents of the file to base64:

    bash

    Create a Kubernetes secret file secret.yaml and put the output of the previous command to the data.secret field. For example:

    yaml

    Apply this secret to the Core Cluster where you want to perform backups using the following command:

    bash
  2. Prepare the DBBackup Custom Resource (CR) to deploy the Cennso Database Backup in your Management Cluster. This CR defines the connection to the Core Cluster and the backup job configuration. For example:

    yaml

    Important

    The DBBackup resource has restrictions on some configurable values. For more information, see the Configuration restrictions section.

  3. Apply the prepared CR to your Management Cluster:

    bash
  4. Check your Core Cluster for the created Kubernetes CronJob to check if backups are configured to run at the specified time:

    bash

The example above shows the Custom Resource that creates a Kubernetes CronJob. This CronJob performs a backup of the database deployed in the Core Cluster specified by the {CORE-CLUSTER-NAME} and located in the namespace specified by the {NAMESPACE-WITH-MYSQL-CLUSTER}. It performs a backup each day at 00:00. The {SECRET-NAME} must specify the name of the Kubernetes secret which you created in the previous step.

For more information about available configuration options, see the Cennso Database Backup document.

Restore a database from a backup

If your database or the data was corrupted in a way that you can not continue to run MySQL instances on existing data files, you have to restore the database from a backup.

To restore the database from a backup, you must deploy a new MySQL cluster using the instructions given in the Deploy Cennso Database document or scale the existing cluster to zero instances. To learn how to deploy a new MySQL cluster, read the Installation and Deploy Cennso Database documents. To scale down your existing cluster, you can use the command line or Cennso Management Console:

Important

Be sure you know the node names where the MySQL instances are deployed before you scale down your database cluster. If you are using the Cennso Management Console, you can find the nodes where your MySQL instances are deployed at the Cennso Management → Configurations. Choose the DBInstance related to your MySQL cluster and check the nodes at the specification tab. If you are using the CLI, you can use the following command to get the nodes on the Core Cluster where your MySQL cluster is deployed:

bash

To scale down the MySQL cluster using CMC:

  1. Go to Cennso Management → Configurations.
  2. Use filters at the top menu to select the DBInstance kind. Then, choose the DBInstance related to your MySQL cluster.
  3. Press the Edit button and switch to the Specification tab.
  4. Set the value of the MySQL cluster size to 0.

After this, follow the next steps to restore your database from a backup:

  1. Go to nodes where the MySQL cluster is deployed and remove the broken MySQL datadirOpens in a new tab:

    bash
  2. Go to the node where the primary MySQL instance is intended to run after restoring the backup. Find the snapshot ID in Restic from which you want to restore and fetch it to the node:

    bash
  3. Restore the backup using the xtrabackupOpens in a new tab command:

    bash

    Note

    If you set the --compress option in the spec.xtradbExtraArgs of the DBBackup Custom Resource, you should decompress the backup before restoring from it. To do that, use the following commands:

    bash
  4. Delete the directory with the backup:

    bash
  5. From now on, you can scale your MySQL cluster to the desired number of instances again. To do this, you can use the Cennso Management Console or the CLI. Repeat step 1 above to set the number of MySQL instances as expected.

    Important

    In addition, it is highly recommended to enable MySQL CLONEOpens in a new tab and disable binary-donor after you restore the backup.

    To enable CLONE operations, you can set the CLONE_REQUIRED_ON_ASYNC_CLUSTER environment variable to true in the PerconaServerMySQL resource related to your MySQL cluster. To disable binary-donor, scale its deployments to 0.

    After the database cluster is up and running and the CLONE operation finishes, you can set the value of the CLONE_REQUIRED_ON_ASYNC_CLUSTER back to false and enable binary-donor again. After restarting the MySQL instances, you should have a ready MySQL cluster with restored data.

    For more information on how to validate your MySQL cluster, see the Validate the MySQL cluster document.