Restoring Db2 with a custom resource

You can use a custom resource to restore your Db2 database.

Before you begin

To restore a Db2 database, you need:
  • A deployed Db2 database in Ready state.
  • A completed backup operation to restore from.

About this task

Creating the restore custom resource starts the restore operation.

The type of backup operation specified in the backup's custom resource determines the type of restore operation. For an incremental backup, the restore custom resource sets a flag for an automatic incremental backup, which allows only one backup designation for the restore operation. To restore all of your most recent changes, specify the last incremental backup.

Important: If you have already restored from a backup, do not restore from another backup made before that restore operation. Doing so can result in issues such as dropping the database before the next restore, which will require manual intervention.

Procedure

  1. Create a custom resource to define the restore operations for your deployment.
    Refer to the following example to help define your custom resource. Replace the variables with details for your environment.
    apiVersion: db2ubnr.databases.ibm.com/v1alpha1
    kind: Db2uRestore
    metadata:
      name: <name of your db2urestore>
    spec:
      db2uCluster: <name of your db2ucluster>
      db2uBackup: <name of your db2ubackup>
    • Replace <name of your db2urestore> with a valid Kubernetes resource name. A restore name cannot be reused, even after the restore has been deleted.
    • Replace <name of your db2ucluster> with the name of your deployed Db2 database.
    • Replace <name of your db2ubackup> with the backup you want to restore from. The backup must be in the same namespace as the restore.
  2. To create the restore, run the following command:
    oc create -f <name of your db2urestore>.yaml
  3. Check the status of your restore by running the following command:
    oc get db2urestore <name of your db2urestore>
    There are 4 possible statuses:
    • InProgress: The backup operation is currently ongoing.
    • Complete: The backup operation was successful.
    • InvalidSpec: There is an error with 1 or more of the fields of the backup's custom resource.
    • Error: The backup operation failed.