Skip to content

Get free database assistance or contact our experts for personalized support.

Making on-demand backup

Before you begin

  1. Export the namespace as an environment variable. Replace the <namespace> placeholder with your value:

    export NAMESPACE = <namespace>
    
  2. Check the configuration of the PerconaServerMySQL object:

    • Check that the backup.enabled key is set to true. Use the following command:
    kubectl get ps <cluster-name> -n $NAMESPACE -o jsonpath='{.spec.backup.enabled}'
    
    • Verify that you have configured backup storage and specified its configuration in the backup.storages subsection of the Custom Resource.

Backup steps

To make an on-demand backup, use a special backup configuration YAML file. The example of such file is deploy/backup/backup.yaml .

You can check available options in the Backup resource reference

Specify the following keys:

  • Set the metadata.name key to assign a name to the backup.
  • Set the spec.clusterName key to the name of your cluster.
  • Set the spec.storageName key to a storage configuration defined in your deploy/cr.yaml file.
  • Optionally, add the percona.com/delete-backup entry under metadata.finalizers to enable deletion of backup files from a cloud storage when the backup object is removed (manually or by schedule).

Pass this information to the Operator:

  1. Edit the deploy/backup/backup.yaml file:

    apiVersion: ps.percona.com/v1
    kind: PerconaServerMySQLBackup
    metadata:
      name: backup1
      finalizers:
        - percona.com/delete-backup
    spec:
      clusterName: ps-cluster1
      storageName: s3-us-west
    
  2. Start the backup process:

    kubectl apply -f deploy/backup/backup.yaml -n $NAMESPACE
    

Instead of storing backup settings in a separate file, you can pass them directly to the kubectl apply command as follows:

cat <<EOF | kubectl apply -n $NAMESPACE -f-
apiVersion: ps.percona.com/v1
kind: PerconaServerMySQLBackup
metadata:
  name: backup1
  finalizers:
    - percona.com/delete-backup
spec:
  clusterName: ps-cluster1
  storageName: s3-us-west
EOF

List backups with this command:

kubectl get ps-backup -n $NAMESPACE

Specifying the backup source

When you create a backup object, the Operator selects a Pod to take the backup from. You can see the backup source pod in the backup object’s status:

kubectl get ps-backup backup1 -o yaml
Sample output
apiVersion: ps.percona.com/v1
kind: PerconaServerMySQLBackup
metadata:
  name: backup1
  ...
status:
  backupSource: cluster1-mysql-1.cluster1-mysql.<namespace>
  ...

You can specify the source pod in the backup object to run the backup on this specific pod:

apiVersion: ps.percona.com/v1
kind: PerconaServerMySQLBackup
metadata:
  name: backup1
  finalizers:
    - percona.com/delete-backup
spec:
  clusterName: ps-cluster1
  storageName: s3-us-west
  sourcePod: ps-cluster1-mysql-2

Troubleshooting

If you face issues with backups, refer to our Backup troubleshooting guide for help.


Last update: 2025-11-17