Configure backup storage
Before configuring backups, you must set up a backup storage location.
-
Create a Kubernetes secret using your cloud storage credentials.
apiVersion: v1data:AWS_ACCESS_KEY_ID: YOUR_ACCESS_KEY_ID_BASE64_ENCODEDAWS_SECRET_ACCESS_KEY: YOUR_SECRET_ACCESS_KEY_BASE64_ENCODEDkind: Secretmetadata:name: my-s3-backup-storagetype: Opaque -
Create a
BackupStorageCRD that references this secret.apiVersion: everest.percona.com/v1alpha1kind: BackupStoragemetadata:name: my-s3-backup-storagespec:bucket: my-s3-bucketcredentialsSecretName: my-s3-backup-storagedescription: My S3 backup storageendpointURL: https://my-s3-endpoint.comforcePathStyle: falseregion: us-west-2type: s3verifyTLS: true -
Configure backup schedules in your
DatabaseCluster.spec:backup:schedules:- name: "daily-backup"enabled: trueschedule: "0 0 * * *" # Daily at midnightretentionCopies: 7backupStorageName: "my-s3-backup-storage"pitr: # Point-in-Time Recoveryenabled: truebackupStorageName: "my-s3-backup-storage"uploadIntervalSec: 300 # 5 minutes
Manual backups and restores
In addition to scheduled backups, you can create manual backups and perform restores using the DatabaseClusterBackup and DatabaseClusterRestore CRDs.
Create a manual backup
Define a DatabaseClusterBackup object:
apiVersion: everest.percona.com/v1alpha1
kind: DatabaseClusterBackup
metadata:
labels:
clusterName: my-database-cluster
name: my-database-cluster-backup
spec:
backupStorageName: my-s3-backup-storage
dbClusterName: my-database-cluster
Monitor the backup status:
kubectl get dbbackup manual-backup-2024-04-11 -o jsonpath='{.status}'
A backup typically progresses through these states:
-
Starting: Initial backup preparation
-
Running: Backup in progress
-
Succeeded: Backup completed successfully
-
Failed: Backup failed
Restore from a backup
You can restore from a backup in two ways:
-
Restore from a
DatabaseClusterBackup.apiVersion: everest.percona.com/v1alpha1kind: DatabaseClusterRestoremetadata:name: restore-from-backupspec:dbClusterName: my-database-clusterdataSource:dbClusterBackupName: my-database-cluster-backup -
Restore to a new database cluster.
To restore a backup to a new database cluster, create a new
DatabaseClusterwith thedataSourcefield that references the backup:apiVersion: everest.percona.com/v1alpha1kind: DatabaseClustermetadata:name: restored-databasenamespace: defaultspec:# .. hiddendataSource:dbClusterBackupName: backup-name-here # Name of the backup to restore from
- The new cluster must use the same type and version of database engine as the backup.
- The storage size of the new cluster should be at least as large as that of the original cluster.
- The new cluster will be created in the same namespace as the backup.
- Other configurations, such as proxy settings and monitoring, may differ from those of the original cluster.
Perform Point-in-Time Recovery (PITR)
You can perform a point-in-time recovery to restore your database to a specific moment in time.
apiVersion: everest.percona.com/v1alpha1
kind: DatabaseClusterRestore
metadata:
name: pitr-restore
spec:
dbClusterName: my-database
dataSource:
dbClusterBackupName: base-backup
pitr:
type: date
date: "2024-04-11T15:30:00Z" # UTC timestamp
Monitor the restore status:
kubectl get dbrestore restore-from-backup -o jsonpath='{.status}'
The restore will typically go through these states:
- Starting: Initial restore preparation
- Restoring: Restore in progress
- Succeeded: Restore completed successfully
- Failed: Restore failed