Backing up Db2 with a custom resource

You can use a custom resource to configure a backup operation for your Db2 database.

Before you begin

To start a backup operation, you need to deploy a database instance of Db2. For more information, see Creating a service instance for Db2.

About this task

Creating the custom resource starts the Db2 backup operation. The Db2 operator manages the lifecycle of this resource. The operator also reports the completion status of the resource and contains logs about the status of the backup operation.

You can configure the following types of database backups:
  • Full offline backup
  • Full online backup
  • Incremental online backup
Important: Online backups require the TRACKMOD configuration parameter to be set to Yes. For more information on backup types, see Backing up and restoring a database, schema, or table.

Procedure

  1. Create a Db2uBackup custom resource to define the backup 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: Db2uBackup
    metadata:
      name: <name of your db2ubackup>
    spec:
      db2uName: <name of your db2ucluster or db2uinstance>
      databaseBackup:
        dbName: <name of your database> 
        type: <offline | online | incremental>
        backupTarget:
          vendor: "disk"
    • Replace <name of your db2ubackup> with a valid Kubernetes resource name. A backup name cannot be reused, even after the backup is deleted.
    • Replace <name of your db2ucluster or db2uinstance> with the name of your deployed Db2 database.
    • Replace <name of your database> with the name of the database that you want to back up.
    • Replace <offline | online | incremental> with the type of backup operation that you want to use.
  2. To create the backup, run the following command:
    oc create -f <name of your db2ubackup>.yaml
  3. Check the status of your backup by running the following command:
    oc get db2ubackup <name of your db2ubackup>

    The command returns the following possible statuses:

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

What to do next

To restore from your backup, see Restoring Db2 with a custom resource.