Backup and restore (legacy) commands

For application workloads, use these oc commands to create and manage backup storage location, backup policy, restore backup, and application.

If you are not currently in the same namespace, then include -n <namespace> in all commands. If you are already in the IBM Storage Fusion namespace (ibm-spectrum-fusion-ns), then -n <namespace> is not required.

Backup storage location

Create a backup storage location
oc create -f <storagelocation.yaml>
Sample storage location YAML file:
apiVersion: v1
data:
  access-key-id: AMIATNJ3JEMKR6GAUOLN
  secret-access-key: vgm9AJPztPkOygBFpBp2UzEErLBelTcp3JPdPn9c
kind: Secret
metadata:
  name: backup-storage-location-example-secret-0
  namespace: ibm-spectrum-fusion-ns
---
apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: BackupStorageLocation
metadata:
  annotations:
    dp.isf.ibm.com/provider-name: isf-ibmspp
  name: backup-storage-location-example
  namespace: ibm-spectrum-fusion-ns
spec:
  type: aws
  credentialName:  backup-storage-location-example-secret-0
  provider: isf-ibmspp
  params:
    region: us-west-2
    bucket: bucket-name
    endpoint: https://s3.us-west-2.amazonaws.com

In this sample, a secret and backup storage locations are created.

Note: The secret is created before the triple dashes, and the backup storage location is created after the triple dashes in the YAML file.
Run the following command to generate the cloud data:
printf "[default]\naws_access_key_id=minio\naws_secret_access_key=minio123\n" | base64 -w 0

Replace the value of aws_access_key_id and aws_secret_access_key with your value.

Modify backup storage location
oc edit fbsl backup-storage-location-example

You can modify the backup storage location details.

Modify secret
oc edit secret backup-storage-location-example-secret-0

You can modify the secret details.

Delete backup storage location
oc delete fbsl backup-storage-location-example
Note: If backup policies exist that use the backup storage location, then you cannot delete it.
Delete secret
oc delete secret backup-storage-location-example-secret-0
Get all backup storage locations
oc get fbsl

Backup policy

Create a backup policy
oc create -f <backuppolicy.yaml>
or
oc apply -f <backuppolicy.yaml>
Sample backup policy YAML files:
  • Backup policy to take backups daily:
    apiVersion: data-protection.isf.ibm.com/v1alpha1
    kind: BackupPolicy
    metadata:
      name: daily-policy
      namespace: ibm-spectrum-fusion-ns
    spec:
      provider: isf-ibmspp
      backupStorageLocation: backup-storage-location-example
      retention:
        number: 10
        unit: days
      schedule:
        cron: "30 10 * * *"
        
  • Backup policy to take backups weekly from Monday through Friday:
    apiVersion: data-protection.isf.ibm.com/v1alpha1
    kind: BackupPolicy
    metadata:
      name: backup-policy-weekdays
      namespace: ibm-spectrum-fusion-ns
    spec:
      provider: isf-ibmspp
      backupStorageLocation: backup-storage-location-example
      retention:
        number: 4
        unit: weeks
      schedule:
        cron: "30 20 * * 1,2,3,4,5"
Edit a backup policy
oc edit backuppolicy <backuppolicy name>

You cannot modify the policy name and CR name.

Delete a backup policy
oc delete backuppolicy <backuppolicy name>
Example:
oc delete backuppolicy daily-policy

If at least one reference exists a backupObject or PolicyAssignment Object, then you cannot delete the policy.

Get the basic information about a backup policy
oc get backuppolicy <backuppolicy name>
Get all the information about a backup policy
oc describe backuppolicy daily-policy 
Alternatively, you can use the following sample OC command:
oc describe backuppolicy/daily-policy
Get all backup policies
oc get backuppolicies
Assign a policy to an application
BackupPolicyAssignment is a call to create backups by associating a backup policy with an application. You must assign a policy to an application to schedule backups.
oc create -f <policyassignment.yaml>
Sample assignment YAML file for daily backup:
apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: PolicyAssignment
metadata:
  name: backup-policy-assignment-example
  namespace: ibm-spectrum-fusion-ns
spec:
  application: application-sample
  backupPolicy: daily-policy
  
Here, the policy backup-policy-hourly is assigned to the application-sample application.
Example with annotation:

apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: PolicyAssignment
metadata:
  annotations:
    dp.isf.ibm.com/provider-name: isf-ibmspp
  labels:
    dp.isf.ibm.com/application-name: filebrowser-20220919-1834111
    dp.isf.ibm.com/backuppolicy-name: isf-auto-ibmcos-backuppolicy-20220919-183411
    dp.isf.ibm.com/backupstoragelocation-name: isf-ibm-location-20220919-183411
  name: filebrowser-20220919-1834111-isf-auto-ibmcos-backuppolicy-20220919-183411
  namespace: ibm-spectrum-fusion-ns
spec:
  application: filebrowser-20220919-1834111
  backupPolicy: isf-auto-ibmcos-backuppolicy-20220919-183411
  runNow: true
The corresponding backup CRD file is as follows:

apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: BackupPolicy
metadata:
  annotations:
    dp.isf.ibm.com/provider-name: isf-ibmspp
  name: isf-auto-ibmcos-backuppolicy-20220919-183411
  namespace: ibm-spectrum-fusion-ns
spec:
  backupStorageLocation: isf-ibm-location-20220919-183411
  provider: isf-ibmspp
  retention:
    number: 1
    unit: days
  schedule:
    cron: 51 18 1 * *
    timezone: America/Los_Angeles
Edit policy assignment
oc edit policyassignment <policyassignment-name>
Delete policy assignment
oc delete policyassignment <policyassignment-name>

Backup and restore

Create backup CR for on-demand backup
Here, one time application backup is taken by using an on-demand backup policy.
oc create -f <CR_Ondemand_backup.yaml> 
Sample YAML file:
apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: Backup
metadata:
  name: default-aws-policy-1648483840
  namespace: ibm-spectrum-fusion-ns
  labels:
    dp.isf.ibm.com/application-name: default
    dp.isf.ibm.com/backuppolicy-name: my-aws-s3-policy
    dp.isf.ibm.com/backupstoragelocation-name: my-aws-s3
spec:
  application: default
  backupPolicy: my-aws-s3-policy
Delete backup request CR
A DeleteBackupRequest can be used to delete a backup CR and all the related resources (backup data, snapshot, and so on) of a backup CR.
oc create -f <delete_CR_Name.yaml>

Sample YAML file:

apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: DeleteBackupRequest
metadata:
  name: backup-example-delete-request
  namespace: ibm-spectrum-fusion-ns
spec:
  backup: backup-example
Restore an application
oc create -f <backup-restore.yaml>

Sample of YAML restore file:

The following sample restores the backup-wordpress backup.
apiVersion: data-protection.isf.ibm.com/v1alpha1
kind: Restore
metadata:
  name: wordpress-restore1
  namespace: ibm-spectrum-fusion-ns
spec:
  backup: backup-wordpress
  # policyAssignment: backup-policy-on-demand-to-minio
List backups
oc get backups.data-protection.isf.ibm.com
List restores
oc get restores.data-protection.isf.ibm.com
List policy assignments
oc get policyassignments.data-protection.isf.ibm.com