Backup and Restore instructions for DevOps Plan
This section outlines the steps to backup and restore the DevOps Plan resources and persistent volumes that are deployed in the devopsplan namespace with the release name hcl-devopsplan.
About this task
Note: Velero does not backup or restore
hostPath
volumes directly. If your KubernetesOpenShift
setup uses hostPath volumes, you cannot use Velero's backup and restore
functionality for those volumes. Delete the backup namespace as well to prevent potential
MinIO repository corruption after uninstallating Velero/Minio.Procedure
-
Annotate the pods for backups.
Run the following script. When prompted, enter the namespace as devopsplan. This script annotates all pods in the devopsplan namespace with their volume names for Velero backup:
read -p "Enter namespace: " ns; \ kubectl get pods -n "$ns" -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | \ while read pod; do \ vols=$(kubectl get pod "$pod" -n "$ns" -o jsonpath='{.spec.volumes[*].name}' | tr ' ' ','); \ echo "Annotating $pod with volumes: $vols"; \ kubectl annotate pod "$pod" -n "$ns" backup.velero.io/backup-volumes="$vols" --overwrite; \ doneread -p "Enter namespace: " ns; \ oc get pods -n "$ns" -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | \ while read pod; do \ vols=$(oc get pod "$pod" -n "$ns" -o jsonpath='{.spec.volumes[*].name}' | tr ' ' ','); \ echo "Annotating $pod with volumes: $vols"; \ oc annotate pod "$pod" -n "$ns" backup.velero.io/backup-volumes="$vols" --overwrite; \ doneNote: Failing to annotate the pods will result in persistent volume claim (PVC) data not being backed up or restored when using storage classes that do not support Container Storage Interface (CSI) snapshots. -
Create a backup:
velero backup create <Backup_Name> --include-namespaces devopsplan -n backup
Replace
<Backup_Name>with a name of your choice for the backup. -
Verify the backup:
velero backup get -n backup -
To restore:
To restore the DevOps Plan resources and persistent volumes from the previously created backup:
velero restore create --from-backup <Backup_Name> -n backupReplace
<Backup_Name>with a name of your choice for the backup. -
To uninstall or delete the backup and restore a Helm chart:
helm delete backup -n backup helm delete ns backupNote: Velero does not backup or restore hostPath volumes directly. If your Kubernetes setup uses hostPath volumes, you won't be able to use Velero's backup and restore functionality for those volumes.