Backing up and restoring data

Back up your critical data. If you ever need to restore your WebSphere Automation installation and data later, you can restore them from the backup.

Note: This procedure is for backing up and restoring data to the same cluster. If you need to restore data to a different cluster (for example, for disaster recovery), see Backing up and restoring data on different clusters.

You can back up data in the Mongo database and the associated password, encryption keys, and other important data. In WebSphere Automation 1.4.4 and later, the WebSphere Automation custom resources that are deployed are also backed up and restored.

Before you begin

Prepare a host
Complete the following steps on your host:
  1. Install the oc Red Hat OpenShift Container Platform CLI tool.
  2. Download and install the most recent version of IBM Catalog Management Plug-in for IBM Cloud Paks from IBM/ibm-pak External link icon. Extract the binary file by entering the following command:
    tar -xf oc-ibm_pak-linux-amd64.tar.gz

    Run the following command to move the file to the /usr/local/bin directory:

    Note: If you are installing as a non-root user you must use sudo. For more information, refer to the Podman or Docker documentation for installing as a non-root user.
    mv oc-ibm_pak-linux-amd64 /usr/local/bin/oc-ibm_pak
    Note: Download the plug-in based on the host operating system. You can confirm that oc ibm-pak -h is installed by running the following command:
    oc ibm-pak --help

    The plug-in usage is displayed.

    For more information on plug-in commands, see command-help External link icon.

    The plug-in is also provided in a container image cp.icr.io/cpopen/cpfs/ibm-pak:TAG, where TAG should be replaced with the corresponding plug-in version, for example, cp.icr.io/cpopen/cpfs/ibm-pak:v1.2.0 for version 1.2.0 of the plug-in.

The following command creates a container and copies the plug-ins for all the supported platforms in a directory, plugin-dir. You can specify any directory name and it will be created while copying. After copying, it deletes the temporary container. The plugin-dir has all the binaries and other artifacts you find in a GitHub release and repository at IBM/ibm-pak External link icon.

id=$(docker create cp.icr.io/cpopen/cpfs/ibm-pak:TAG - )
docker cp $id:/ibm-pak plugin-dir
docker rm -v $id
cd plugin-dir
Set environment variables and download CASE files
  1. Create the following environment variables with the installer image name and the version.
    export CASE_NAME=<YOUR_CASE_NAME>
    export CASE_VERSION=<YOUR_CASE_VERSION>
    To find the CASE name and version, see IBM: Product CASE to Application Version External link icon. For WebSphere Automation:
    • <YOUR_CASE_NAME> is ibm-websphere-automation
    • <YOUR_CASE_VERSION> is the same as the product version (1.8.0).
  2. Set the locale, if you do not want to use the locale that the plug-in detects for textual helps and messages.
    oc ibm-pak config locale -l <LOCALE>

    Where <LOCALE> can be one of de_DE, en_US, es_ES, fr_FR, it_IT, ja_JP, ko_KR, pt_BR, zh_Hans, or zh_Hant.

  3. Configure the plug-in to download CASEs as OCI artifacts from IBM Cloud Container Registry (ICCR).
    oc ibm-pak config repo 'IBM Cloud-Pak OCI registry' -r oci:cp.icr.io/cpopen --enable
  4. Enable color output (optional with version 1.4.0 and later).
    oc ibm-pak config color --enable true
  5. Download the image inventory for WebSphere Automation to your host.
    Tip: If you do not specify the CASE version, it downloads the latest CASE.
    oc ibm-pak get \
       $CASE_NAME \
       --version $CASE_VERSION

By default, the root directory that is used by plug-in is ~/.ibm-pak. This means that the preceding command downloads the CASE under ~/.ibm-pak/data/cases/$CASE_NAME/$CASE_VERSION. You can configure this root directory by setting the IBMPAK_HOME environment variable. Assuming the IBMPAK_HOME variable is set, the preceding command downloads the CASE under $IBMPAK_HOME/.ibm-pak/data/cases/$CASE_NAME/$CASE_VERSION.

The logs files are available at $IBMPAK_HOME/.ibm-pak/logs/oc-ibm_pak.log.

Note:
  • Starting with v1.4.0, the plug-in creates a file, component-set-config.yaml, in the directory ~/.ibm-pak/data/cases/$CASE_NAME/$CASE_VERSION to download the CASEs with oc ibm-pak get. This file captures all the CASEs that were downloaded, pinning down their exact versions during this particular download. You can use this file later to download the same CASEs with same versions in another environemnt. You can check in this file to your source code repository and re-create the same environment each time you use this to download the CASEs. Run the following command:
    oc ibm-pak get -c file:///home/user/ibm-pak/data/cases/$CASE_NAME/$CASE_VERSION/component-set-config.yaml

    The path after file:// should be an absolute path.

  • You can edit this file defining the CASEs with pinned down versions that should include your product. The following is an example file, my-csc.yaml:
       name: "example-product"                         # <required> defines the name for the "product"; this is NOT a CASE name, but follows IBM CASE name rules. For more information, see https://ibm.biz/case-yaml
       version: "1.0.0"                                # <required> defines a version for the "product"
       description: "an example product targeting OCP 4.12" # <optional, but recommended> defines a human readable description for this listing of components
       cases:                                          # list of CASEs. First item in the list is assumed to be the "top-level" CASE, and all others are dependencies
      - name: ibm-mas
        version: 5.5.2
        launch: true                                  # Exactly one CASE should have this field set to true. The launch scripts of that CASE are used as an entry point while executing 'ibm-pak launch' with a ComponentSetConfig
      - name: ibm-cp-common-services
        version: 1.15.2

Backing up data

Run the backup action to back up data. Replace instance_namespace with the namespace of the WebSphere Automation instance to back up.


oc ibm-pak launch $CASE_NAME \
 --version $CASE_VERSION \
 --inventory automationOperator \
 --action backup \
 --namespace instance_namespace

The backup action requires a persistent volume to store the backup information. By default, the action creates the volume dynamically. If dynamic storage provisioning is not supported or you want to use a different persistent volume, add the following arguments for an existing persistent volume claim (PVC).

--args "--claim persistent_volume_name"
Tip: Use an encrypted persistent volume for backups because the backup data can contain credentials and other sensitive information.

The backup action starts a job that backs up the data and resources. The output of the backup action shows a separate command to run to obtain the logs of that job.

Each time the backup action runs, it creates a unique directory with the backup data on the persistent volume. The unique directory name has a timestamp that is based on the time and date when the command was run; for example, 20210528-120120. You use the directory name to restore the data from a backup.

Restoring data

You can recover an existing WebSphere Automation installation data from a backup. The recovery process involves deleting the existing data to put the installation in an initial state and then restoring the data from a backup. Recovering a WebSphere Automation installation to another namespace in the same or another Red Hat OpenShift cluster is not currently supported.

In WebSphere Automation 1.4.4 and later, custom resources are backed up and restored. Therefore, it is not necessary to scale the replicas back up for the various components (steps 7, 8, and 9 in the following list).

  1. Find the backup timestamp from which you want to recover. To list the available backups, run the restore action without any arguments.
    oc ibm-pak launch $CASE_NAME \
     --version $CASE_VERSION \
     --inventory automationOperator \
     --action restore \
     --namespace instance_namespace

    The restore action starts a job that lists the available backups. The output of the restore action shows a separate command to run to obtain the logs of that job. The logs contain the list of available backups.

  2. Scale the number of replicas for all WebSphere Automation to zero.

    You can do this by setting the spec.scaleToZero parameter in the WebSphereAutomation custom resource to true. For more information see WebSphereAutomation custom resource.

    WSA_INSTANCE_NAMESPACE=instance_namespace		
    WSA_AUTOMATION_CR=$(oc get websphereautomation -o name -n $WSA_INSTANCE_NAMESPACE | cut -d/ -f2) 
    oc patch websphereautomation $WSA_AUTOMATION_CR -p '{"spec":{"scaleToZero":true}}' --type merge -n $WSA_INSTANCE_NAMESPACE
    The scale to zero operation can take 1-2 minutes to complete. You get an empty result if the operation is completed.
    oc get pods -n $WSA_INSTANCE_NAMESPACE | grep Running | grep -v $WSA_AUTOMATION_CR-mongo | grep $WSA_AUTOMATION_CR-
  3. Delete existing WebSphere Automation data.
    Warning: The delete commands in this step delete existing data! If you are unsure about this step, consider cloning all the WebSphere Automation persistent volumes External link icon first.
    1. Scale the data store replicas to zero.
      oc patch websphereautomation $WSA_AUTOMATION_CR -p '{"spec":{"dataStore":{"replicas":0}}}' --type merge -n $WSA_INSTANCE_NAMESPACE
      To validate that the data store is scaled down:
      oc get pods -n $WSA_INSTANCE_NAMESPACE | grep Running | grep $WSA_AUTOMATION_CR-mongo
    2. Delete persistent volume claims (PVC) associated with the data store.
      oc delete pvc -l app.kubernetes.io/instance=${WSA_AUTOMATION_CR}-mongo -n $WSA_INSTANCE_NAMESPACE 
    3. Scale the data store replicas back.
      oc patch websphereautomation $WSA_AUTOMATION_CR -p '{"spec":{"dataStore":{"replicas":3}}}' --type merge -n $WSA_INSTANCE_NAMESPACE
    4. Ensure that the WebSphere Automation operator re-created the PVCs and that the data store is ready. You want the command output to be True.
      oc get websphereautomation $WSA_AUTOMATION_CR -o jsonpath='{.status.conditions[?(@.type=="DataStoreReady")].status}' -n $WSA_INSTANCE_NAMESPACE && echo
  4. To restore from a backup, run the restore action with the --timestamp argument. Replace timestamp with the timestamp of the backup directory that you want to restore.
    oc ibm-pak launch $CASE_NAME \
     --version $CASE_VERSION \
     --inventory automationOperator \
     --action restore \
     --namespace $WSA_INSTANCE_NAMESPACE \
     --args "--timestamp <timestamp>"

    The restore action starts a job that restores the data and resources. The output of the restore action shows a separate command to run to get the logs of that job.

    Note: If the restore action is not run immediately after the previous step, the log files might indicate that some documents failed to restore.
    continuing through error: E11000 duplicate key error collection: webspheresecuredb.bulletins index: _id_ dup key: { _id: "3d7329df-abec-377d-bf5e-1181947b6c0d" }

    You can ignore these log entries because the collection is automatically populated when a new instance is created or restored.

After restoration, confirm that the restored installation runs as wanted, and that the data is available.

Note: If it is necessary to run the restore command again for a backup, it is necessary to remove the previous job that was run. To do so, get a list of jobs by using the following command:
oc get job -n $WSA_INSTANCE_NAMESPACE | grep wsa-restore

Delete the job that has wsa-restore as part of the name.

oc delete job job_name -n $WSA_INSTANCE_NAMESPACE