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.

Procedure

  1. 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; \
    done
    Note: 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.
  2. 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.

  3. Verify the backup:
      velero backup get -n backup
  4. To restore:
    To restore the DevOps Plan resources and persistent volumes from the previously created backup:
      velero restore create --from-backup <Backup_Name> -n backup

    Replace <Backup_Name> with a name of your choice for the backup.

  5. To uninstall or delete the backup and restore a Helm chart:
    helm delete backup -n backup
    Note: 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.