English | 简体中文
- You need to deploy the RadonDB MySQL cluster.
This tutorial displays how to back up and restore the deployed RadonDB MySQL Operator cluster.
kind: Secret
apiVersion: v1
metadata:
name: sample-backup-secret
namespace: default
data:
s3-endpoint: aHR0cDovL3MzLnNoMWEucWluZ3N0b3IuY29t
s3-access-key: SEdKWldXVllLSENISllFRERKSUc=
s3-secret-key: TU44TkNUdDJLdHlZREROTTc5cTNwdkxtNTlteE01blRaZlRQMWxoag==
s3-bucket: bGFsYS1teXNxbA==
type: Opaque
The value s3-xxxx
is base64-encoded. You can encode the value as follows, and do not encode line breaks.
echo -n "your value"|base64
Then, create the backup Secret.
kubectl create -f config/samples/backup_secret.yaml
Configure the backupSecretName
property in mysql_v1alpha1_mysqlcluster.yaml
, for example, sample-backup-secre
.
spec:
replicas: 3
mysqlVersion: "5.7"
backupSecretName: sample-backup-secret
...
Create the backup YAML file mysql_v1alpha1_backup.yaml
as follows.
apiVersion: mysql.radondb.com/v1alpha1
kind: Backup
metadata:
name: backup-sample1
spec:
# Add fields here
hostName: sample-mysql-0
clusterName: sample
Parameter | Description |
---|---|
hostName | Pod name |
clusterName | Cluster name |
Before starting the backup, you need to start the cluster.
kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml
After starting the backup successfully, view the backup status as follows.
kubectl get backups.mysql.radondb.com
NAME BACKUPNAME BACKUPDATE TYPE
backup-sample sample_2022526155115 2022-05-26T15:51:15 S3
Check the S3 bucket and set the RestoreFrom
property in the mysql_v1alpha1_mysqlcluster.yaml
file to the backup directory, for example, sample_2022526155115
.
...
spec:
replicas: 3
mysqlVersion: "5.7"
backupSecretName: sample-backup-secret
restoreFrom: "sample_2022526155115"
...
Then, start the cluster and the database will be restored from the backup directory.
kubectl apply -f config/samples/mysql_v1alpha1_mysqlcluster.yaml