Configure PVCs for Velero backup and restore
This topic describes how to prepare Storage Autoscaling Persistent Volume Claims (PVCs) for backup and restore with Velero while maintaining data consistency and reliability.
To properly prepare the PVCs, you’ll do the following:
Ensure that all Pods associated with the PVCs to be backed up are labeled.
Labeling controls:which Pods are backed up
which Pods run backup hooks
which Pods are affected by the hook command
Define and apply a backup configuration that includes filesystem hooks.
The hooks ensure data integrity by temporarily pausing disk writes during the backup process.
When these steps are complete, you can use Velero to back up or restore PVCs.
Prerequisites
Velero is installed and configured with a compatible backup storage provider.
Storage Autoscaling and its related components are deployed in the K8s cluster.
Velero has permissions to access and back up K8s resources.
To configure PVCs for Velero backup and restore:
Ensure that all relevant Pods are labeled as defined in the backup definition YAML.
To see current Pod labels, run this command:kubectl get pod <pod-name> --show-labels
Create a backup definition YAML with the following content:
apiVersion: velero.io/v1 kind: Backup metadata: name: <backup-name> namespace: velero # Default namespace is velero, but can be changed as needed spec: orLabelSelectors: - matchLabels: <label-key>: <label-value> - matchLabels: app: zesty-storage-agent # Ensures hooks run on Zesty agent pods hooks: resources: - name: fsfreeze-backup-hooks labelSelector: matchLabels: app: zesty-storage-agent # Only runs hooks on Zesty agent pods pre: - exec: container: agent command: - /bin/bash - -c - "zesty-fs-freeze --action freeze --labelSelector <label-key>=<label-value>" timeout: 1s onError: Fail post: - exec: container: agent command: - /bin/bash - -c - "zesty-fs-freeze --action unfreeze --labelSelector <label-key>=<label-value>" timeout: 1s onError: Fail
Apply the backup configuration by running the following command:
kubectl apply -f zesty-backup.yaml
You can now use Velero to back up or restore the PVCs. For more information, see Velero documentation (https://velero.io/docs/).
After backing up, we recommend that you verify that the PVCs and workloads are working as expected.
You can adjust Velero backup retention settings as per your data protection strategy.