Skip to content

Velero

Velero backs up a whole namespace in one Backup, with the PVC data moved to S3. bret restores only the PVCs of that Backup into a scratch namespace and runs the check against them. Your app and its namespace are never touched.

bret restores the PVCs of a Velero Backup into a scratch namespace and runs the check there
  1. bret reads the Backup in the Velero namespace. It refuses a Backup whose volume data a PVC-only restore cannot bring back (see Volume data).
  2. It creates a Velero Restore with includedResources: [persistentvolumeclaims, persistentvolumes], includedNamespaces set to the Restore namespace, and a namespaceMapping to bret-scratch-<hash>. No Deployment, Service or Secret of the backup is restored.
  3. When the Velero Restore is Completed, bret copies the pod-security labels of your namespace and the Secrets and ConfigMaps the check names into the scratch namespace.
  4. It runs the check pod there, with each restored PVC mounted under its source name.
  5. On cleanup the operator deletes the Velero Restore and the scratch namespace.

<hash> is the first 12 hex characters of sha256("<namespace>/<name>") of the Restore.

Key On What bret uses it for
velero.io/backup-name PodVolumeBackup Finds the file system backups of the Backup it is about to restore.
velero.io/pvc-name PodVolumeBackup (annotation) Tells whether a source PVC was saved as file system backup. Such a PVC fails with BackupUnsupported.
velero.io/schedule-name Backup Not read by bret itself. Velero sets it on every Backup of a Schedule, so it is the usual label for backupSelector.labels.

bret also reads these Backup fields: status.phase, status.completionTimestamp, spec.includedNamespaces, spec.excludedNamespaces and spec.snapshotVolumes.

Skip this if Velero already runs. Tested with Velero 1.18.2 (Helm chart 12.2.5) and the AWS plugin v1.14.4 on kind with Kubernetes 1.37:

Terminal window
velero install \
--provider aws \
--plugins velero/velero-plugin-for-aws:v1.14.4 \
--bucket velero \
--secret-file ./velero-credentials \
--backup-location-config "region=us-east-1,s3ForcePathStyle=true,s3Url=https://s3.example.internal" \
--use-node-agent \
--use-volume-snapshots=false \
--features=EnableCSI \
--wait

velero-credentials is an AWS-style credentials file. Do not commit it:

[default]
aws_access_key_id = <access key>
aws_secret_access_key = <secret key>

The node agent (--use-node-agent) moves CSI snapshot data to S3. bret needs that for snapshotMoveData.