
:_mod-docs-content-type: PROCEDURE
[id="oadp-scheduling-backups-doc"]
= Scheduling backups using Schedule CR
include::_attributes/common-attributes.adoc[]
:context: backing-up-applications

[role="_abstract"]
Schedule backup operations by creating a `Schedule` custom resource (CR) with a Cron expression. This helps you to automate recurring backups of your application data at regular intervals.

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

[WARNING]
====
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

. Retrieve the `backupStorageLocations` CRs:
+
[source,terminal]
----
$ oc get backupStorageLocations -n openshift-adp
----
+
[source,terminal]
----
NAMESPACE       NAME              PHASE       LAST VALIDATED   AGE   DEFAULT
openshift-adp   velero-sample-1   Available   11s              31m
----

. Create a `Schedule` CR, as in the following example:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: velero.io/v1
kind: Schedule
metadata:
  name: <schedule>
  namespace: openshift-adp
spec:
  schedule: 0 7 * * *
  template:
    hooks: {}
    includedNamespaces:
    - <namespace>
    storageLocation: <velero-sample-1>
    defaultVolumesToFsBackup: true
    ttl: 720h0m0s
EOF
----
+
where:

`schedule: 0 7 * * *`:: Specifies the `cron` expression to schedule the backup, for example, `0 7 * * *` to perform a backup every day at 7:00.
+
[NOTE]
====
To schedule a backup at specific intervals, enter the `<duration_in_minutes>` in the following format:
[source,terminal]
----
  schedule: "*/10 * * * *"
----
Enter the minutes value between quotation marks (`" "`).
====

`<namespace>`:: Specifies an array of namespaces to back up.
`<velero-sample-1>`:: Specifies the name of the `backupStorageLocations` CR.
`defaultVolumesToFsBackup: true`:: Optional: 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 version 1.1, add the `defaultVolumesToRestic: true` key-value pair when you back up volumes with Restic.

.Verification

* Verify that the status of the `Schedule` CR is `Completed` after the scheduled backup runs:
+
[source,terminal]
----
$ oc get schedule -n openshift-adp <schedule> -o jsonpath='{.status.phase}'
----