Creating a Backup CR

You back up Kubernetes images, internal images, and persistent volumes (PVs) by creating a Backup custom resource (CR).

Prerequisites

  • You must install the OpenShift API for Data Protection (OADP) Operator.

  • The DataProtectionApplication CR must be in a Ready state.

  • Backup location prerequisites:

    • You must have S3 object storage configured for Velero.

    • You must have a backup location configured in the DataProtectionApplication CR.

  • Snapshot location prerequisites:

    • Your cloud provider must have a native snapshot API or support Container Storage Interface (CSI) snapshots.

    • For CSI snapshots, you must create a VolumeSnapshotClass CR to register the CSI driver.

    • You must have a volume location configured in the DataProtectionApplication CR.

Procedure

  1. Retrieve the backupStorageLocations CRs by entering the following command:

    1. $ oc get backupStorageLocations -n openshift-adp

    Example output

    1. NAMESPACE NAME PHASE LAST VALIDATED AGE DEFAULT
    2. openshift-adp velero-sample-1 Available 11s 31m
  2. Create a Backup CR, as in the following example:

    1. apiVersion: velero.io/v1
    2. kind: Backup
    3. metadata:
    4. name: <backup>
    5. labels:
    6. velero.io/storage-location: default
    7. namespace: openshift-adp
    8. spec:
    9. hooks: {}
    10. includedNamespaces:
    11. - <namespace> (1)
    12. includedResources: [] (2)
    13. excludedResources: [] (3)
    14. storageLocation: <velero-sample-1> (4)
    15. ttl: 720h0m0s
    16. labelSelector: (5)
    17. matchLabels:
    18. app=<label_1>
    19. app=<label_2>
    20. app=<label_3>
    21. orLabelSelectors: (6)
    22. - matchLabels:
    23. app=<label_1>
    24. app=<label_2>
    25. app=<label_3>
    1Specify an array of namespaces to back up.
    2Optional: Specify an array of resources to include in the backup. Resources might be shortcuts (for example, ‘po’ for ‘pods’) or fully-qualified. If unspecified, all resources are included.
    3Optional: Specify an array of resources to exclude from the backup. Resources might be shortcuts (for example, ‘po’ for ‘pods’) or fully-qualified.
    4Specify the name of the backupStorageLocations CR.
    5Map of {key,value} pairs of backup resources that have all of the specified labels.
    6Map of {key,value} pairs of backup resources that have one or more of the specified labels.
  3. Verify that the status of the Backup CR is Completed:

    1. $ oc get backup -n openshift-adp <backup> -o jsonpath='{.status.phase}'