How to Backup Kubernetes MySQL Operator Clusters
Oracle’s MySQL Operator for Kubernetes is a convenient way to automate MySQL database provisioning within your cluster. One of the operator’s headline features is integrated hands-off backup support that increases your resiliency. Backups copy your database to external storage on a recurring schedule.
This article will walk you through setting up backups to an Amazon S3-compatible object storage service. You’ll also see how to store backups in Oracle Cloud Infrastructure (OCI) storage or local persistent volumes inside your cluster.
Preparing a Database Cluster
Install the MySQL operator in your Kubernetes cluster and create a simple database instance for testing purposes. Copy the YAML below and save it to mysql.yaml
:
apiVersion: v1 kind: Secret metadata: name: mysql-root-user stringData: rootHost: "%" rootUser: "root" rootPassword: "P@$$w0rd" --- apiVersion: mysql.oracle.com/v2 kind: InnoDBCluster metadata: name: mysql-cluster spec: secretName: mysql-root-user instances: 3 tlsUseSelfSigned: true router: instances: 1
Use Kubectl to apply the manifest:
$ kubectl apply -f mysql.yaml
Wait a few minutes while the MySQL operator provisions your Pods. Use Kubectl’s get pods
command to check on the progress. You should see four running Pods: one MySQL router instance and three MySQL server replicas.
$ kubectl get pods NAME READY STATUS RESTARTS AGE mysql-cluster-0 2/2 Running 0 2m mysql-cluster-1 2/2 Running 0 2m mysql-cluster-2 2/2 Running 0 2m mysql-cluster-router-6b68f9b5cb-wbqm5 1/1 Running 0 2m
Defining a Backup Schedule
The MySQL operator requires two components to successfully create a