// Module included in the following assemblies:
//
// backup_and_restore/application_backup_and_restore/oadp-self-service/oadp-self-service-namespace-admin-use-cases.adoc

:_mod-docs-content-type: PROCEDURE
[id="oadp-self-service-creating-nab_{context}"]
= Creating a NonAdminBackup CR

[role="_abstract"]
Create a `NonAdminBackup` (NAB) custom resource (CR) to back up application resources in your authorized namespace. This helps you to protect your application data and configuration without requiring cluster administrator privileges.

After you create a NAB CR, the CR undergoes the following phases:

* The initial phase for the CR is `New`. 
* The CR creation request goes to the `NonAdminController` (NAC) for reconciliation and validation. 
* Upon successful validation and creation of the `Velero` backup object, the `status.phase` field of the NAB CR is updated to the next phase, which is, `Created`.

Review the following important points when creating a NAB CR:

* The `NonAdminBackup` CR creates the `Velero` backup object securely so that other namespace admin users cannot access the CR.
* As a namespace admin user, you can only specify your authorized namespace in the NAB CR. You get an error when you specify a namespace you are not authorized to use.

.Prerequisites

* You are logged in to the cluster as a namespace admin user.
* The cluster administrator has installed the {oadp-short} Operator.
* The cluster administrator has configured the `DataProtectionApplication` (DPA) CR to enable {oadp-short} Self-Service.
* The cluster administrator has created a namespace for you and has authorized you to operate from that namespace.
* Optional: You can create and use a `NonAdminBackupStorageLocation` (NABSL) CR to store the backup data. If you do not use a NABSL CR, then the backup is stored in the default backup storage location configured in the DPA.

.Procedure

. To create a `NonAdminBackup` CR, create a YAML manifest file with the following configuration:
+
.Example `NonAdminBackup` CR
[source,yaml]
----
apiVersion: oadp.openshift.io/v1alpha1
kind: NonAdminBackup
metadata:
  name: test-nab
spec:
  backupSpec:
    defaultVolumesToFsBackup: true
    snapshotMoveData: false
    storageLocation: test-bsl
----
+
where:

`name`:: Specifies a name for the NAB CR. For example, `test-nab`.
`defaultVolumesToFsBackup`:: Specifies whether to use File System Backup (FSB). Set to `true` to use FSB.
`snapshotMoveData`:: Specifies whether to back up data volumes by using the Data Mover. Set to `true` to use Data Mover. This example uses FSB for backup.
`storageLocation`:: Specifies a NABSL CR as a storage location. If you do not set a `storageLocation`, then the default backup storage location configured in the DPA is used.

. To apply the NAB CR configuration, run the following command:
+
[source,terminal]
----
$ oc apply -f <nab_cr_filename>
----
Replace `<nab_cr_filename>` with the file name containing the NAB CR configuration.

.Verification

* To verify that the NAB CR is successfully created, run the following command:
+
[source,terminal]
----
$ oc get nab test-nab -o yaml
----
+
.Example output
[source,yaml]
----
apiVersion: oadp.openshift.io/v1alpha1
kind: NonAdminBackup
metadata:
  creationTimestamp: "2025-03-06T10:02:56Z"
  finalizers:
  - nonadminbackup.oadp.openshift.io/finalizer
  generation: 2
  name: test-nab
  namespace: test-nac-ns
  resourceVersion: "134316"
  uid: c5...4c8a8
spec:
  backupSpec:
    csiSnapshotTimeout: 0s
    defaultVolumesToFsBackup: true
    hooks: {}
    itemOperationTimeout: 0s
    metadata: {}
    storageLocation: test-bsl
    ttl: 0s
status:
  conditions:
  - lastTransitionTime: "202...56Z"
    message: backup accepted
    reason: BackupAccepted
    status: "True"
    type: Accepted
  - lastTransitionTime: "202..T10:02:56Z"
    message: Created Velero Backup object
    reason: BackupScheduled
    status: "True"
    type: Queued
  dataMoverDataUploads: {}
  fileSystemPodVolumeBackups:
    completed: 2
    total: 2
  phase: Created
  queueInfo:
    estimatedQueuePosition: 0
  veleroBackup:
    nacuuid: test-nac-test-nab-d2...a9b14
    name: test-nac-test-nab-d2...b14
    namespace: openshift-adp
    spec:
      csiSnapshotTimeout: 10m0s
      defaultVolumesToFsBackup: true
      excludedResources:
      - nonadminbackups
      - nonadminrestores
      - nonadminbackupstoragelocations
      - securitycontextconstraints
      - clusterroles
      - clusterrolebindings
      - priorityclasses
      - customresourcedefinitions
      - virtualmachineclusterinstancetypes
      - virtualmachineclusterpreferences
      hooks: {}
      includedNamespaces:
      - test-nac-ns
      itemOperationTimeout: 4h0m0s
      metadata: {}
      snapshotMoveData: false
      storageLocation: test-nac-test-bsl-bf..02b70a
      ttl: 720h0m0s
    status:
      completionTimestamp: "2025-0..3:13Z"
      expiration: "2025..2:56Z"
      formatVersion: 1.1.0
      hookStatus: {}
      phase: Completed
      progress:
        itemsBackedUp: 46
        totalItems: 46
      startTimestamp: "2025-..56Z"
      version: 1
      warnings: 1
----
+
where:

`namespace`:: Specifies the namespace name that the `NonAdminController` CR sets on the `Velero` backup object to back up.
`message: backup accepted`:: Specifies that the NAC has reconciled and validated the NAB CR and has created the `Velero` backup object.
`fileSystemPodVolumeBackups`:: Specifies the number of volumes that are backed up by using FSB.
`phase: Created`:: Specifies that the NAB CR is in the `Created` phase.
`estimatedQueuePosition`:: Specifies the queue position of the backup object. There can be multiple backups in process, and each backup object is assigned a queue position. When the backup is complete, the queue position is set to `0`.
`nacuuid`:: Specifies that the NAC creates the `Velero` backup object and sets the value for the `nacuuid` field.
`name`:: Specifies the name of the associated `Velero` backup object.
`status`:: Specifies the status of the `Velero` backup object.
`phase: Completed`:: Specifies that the `Velero` backup object is in the `Completed` phase and the backup is successful.