Scheduling backups using Schedule CR

The schedule operation allows you to create a backup of your data at a specified time, defined by a Cron expression.

You schedule backups by creating a Schedule custom resource (CR) instead of a Backup CR.

Leave enough time in your backup schedule for a backup to finish before another backup is created.

For example, if a backup of a namespace typically takes 10 minutes, do not schedule backups more frequently than every 15 minutes.

Prerequisites

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

  • The DataProtectionApplication CR must be in a Ready state.

Procedure

  1. Retrieve the backupStorageLocations CRs:

    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 Schedule CR, as in the following example:

    1. $ cat << EOF | oc apply -f -
    2. apiVersion: velero.io/v1
    3. kind: Schedule
    4. metadata:
    5. name: <schedule>
    6. namespace: openshift-adp
    7. spec:
    8. schedule: 0 7 * * * (1)
    9. template:
    10. hooks: {}
    11. includedNamespaces:
    12. - <namespace> (2)
    13. storageLocation: <velero-sample-1> (3)
    14. defaultVolumesToFsBackup: true (4)
    15. ttl: 720h0m0s
    16. EOF
    1cron expression to schedule the backup, for example, 0 7 * to perform a backup every day at 7:00.
    2Array of namespaces to back up.
    3Name of the backupStorageLocations CR.
    4Optional: In OADP version 1.2 and later, add the defaultVolumesToFsBackup: true key-value pair to your configuration when performing backups of volumes with Restic. In OADP 1.1, add the defaultVolumesToRestic: true key-value pair when you back up volumes with Restic.
  3. Verify that the status of the Schedule CR is Completed after the scheduled backup runs:

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