Page
Create a backup from the initial cluster
After we have appropriately installed and configured OpenShift APIs for Data Protection (OADP) and DataProtectionApplication (DPA), we can now move forward with creating a backup of our cluster.
Prerequisites:
- DataProtectionApplication must be installed and reconciled.
- BackupStorageLocation must be Available.
In this lesson, you will:
- Create a backup.
- Monitor and verify the backup you made.
Create a backup custom resource
To start, we’ll create a Backup custom resource to back up the application namespace, including PersistentVolumes (PV) . Optionally, you can verify before creating it.
Verify your OADP operator resources:
oc get dpa -n openshift-adp oc get backupstoragelocation -n openshift-adpCreate the backup using the following command:
cat <<EOF | oc apply -f - apiVersion: velero.io/v1 kind: Backup metadata: name: cert-discovery-app-backup namespace: openshift-adp spec: includedNamespaces: - cert-discovery-app storageLocation: default ttl: 720h0m0s defaultVolumesToFsBackup: false EOFEach field corresponds to specific needs for various backup functions:
Field | Value | Description |
|
| Namespaces to include in backup. |
|
| BackupStorageLocation name. |
|
| Time to live (30 days). |
Warning
Setting defaultVolumesToFsBackup: true is required when the storage provider is not compatible with any CSI driver (https://kubernetes-csi.github.io/docs/drivers.html), so that persistent volumes are backed up using File System Backup (FSB).
Note
If you're using the Alternative: Automated RBAC Backup approach from Prerequisites, use the modified Backup spec shown in that section instead. It includes includedClusterScopedResources and labelSelector to automatically backup ClusterRole and ClusterRoleBinding.
Check the backup phase. This should progress from
NewtoInProgresstoCompleted.oc get backup cert-discovery-app-backup -n openshift-adp \ -o jsonpath='{.status.phase}'
Note
If the backup fails or gets stuck, use oc oadp restore describe cert-discovery-app-restore -n openshift-adp to see detailed error messages.
Wait for the backup to be completed. This could take up to fifteen minutes.
oc wait --for=jsonpath='{.status.phase}'=Completed \ backup/cert-discovery-app-backup -n openshift-adp --timeout=15mExpected output:
backup.velero.io/cert-discovery-app-backup condition metNext, you’ll verify the backup metadata exists:
aws s3 ls s3://cert-discovery-management-app/management-export/backups/cert-discovery-app-backup/ --region eu-north-1As part of the results, you should see the following backup artifacts listed:
cert-discovery-app-backup.tar.gz: Kubernetes resourcescert-discovery-app-backup-logs.gz: Backup logsvelero-backup.json: Backup metadata
Verify Persistent Volume (PV) data in Kopia repository. Kopia writes the PV's contents as deduplicated, encrypted snapshots into a repository inside your backup storage bucket. This confirms Kopia created a repository for the namespace. This is where your PV data (SQLite database) is stored.
aws s3 ls s3://cert-discovery-management-app/management-export/kopia/ --region eu-north-1Expected output:
PRE cert-discovery-app/Optionally, we can verify the Kopia data exists by checking for the Kopia pack files that contain your database:
aws s3 ls s3://cert-discovery-management-app/management-export/kopia/cert-discovery-app/ --region eu-north-1 | grep -E '^2026.*p[0-9a-f]'
You should see multiple files starting with p (pack files, ~20MB each). These are your database backup chunks. If so, you’re good to move on to getting your hosted cluster set up.