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 that is 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 that was 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:
      db2uName: <name of your db2ucluster or db2uinstance>
      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 is deleted.
    • Replace <name of your db2ucluster or db2uinstance> with the name of your deployed Db2 database.
    • Replace <name of your db2ubackup> with the backup that you want to restore from. The backup must be in the same namespace as the restore.
  2. Create the restore by running 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>

    The command returns the following possible statuses:

    • InProgress: The restore operation is ongoing.
    • Complete: The restore operation was successful.
    • InvalidSpec: The restore's custom resource contains an error with 1 or more of the fields.
    • Error: The restore operation failed.