Backing up the License Service Reporter instance

You need to setup OADP on both backup and restore clusters before your back up the License Service Reporter instance.

Prerequisites

Complete the following prerequisites:

  1. Prerequisites of backup and restore for clusters
  2. Create the backup resources for velero objects
  3. Create the backup resource for velero namespace

Back up License Service Reporter instance

To back up the License Service Reporter instance, complete the following steps:

  1. Locate the namespace where the License Service Reporter is installed.

    oc get pods -A | grep ibm-license-service-reporter
    
  2. Change your oc client project to the namespace from the last step.

    oc get project <namespace>
    
  3. Label the necessary secrets that need to be included in the velero backup.

    oc label secret ibm-license-service-reporter-token foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    oc label secret ibm-license-service-reporter-credentials foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    oc label secret ibm-license-service-reporter-credentials-htpasswd foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    
    • For ibm-license-service-reporter-token-<hash value> secret, complete the following steps:

      1. Find the secret name.

        oc get secret | grep ibm-license-service-reporter-token-
        
      2. Label the secret.

        oc label secret ibm-license-service-reporter-token-<hash value> foundationservices.cloudpak.ibm.com=lsr --overwrite=true
        
    • If OIDC is configured for License Service Reporter, complete the following steps to label the secrets:

      1. Find the custom resource of the License Service Reporter instance.

        oc get ibmlicenseservicereporters.operator.ibm.com
        
      2. View the ibmlicenseservicereporters.operator.ibm.com resource and check for the --client-secret-name and --provider-ca-secret-name fields to get the names of the secrets.

        oc get ibmlicenseservicereporters.operator.ibm.com <instance name from last step> -o yaml | grep client-secret-name
        oc get ibmlicenseservicereporters.operator.ibm.com <instance name from last step> -o yaml | grep provider-ca-secret-name
        
      3. Label the secrets.

        oc label secret <client-secret-name> foundationservices.cloudpak.ibm.com=lsr --overwrite=true
        oc label secret <provider-ca-secret-name> foundationservices.cloudpak.ibm.com=lsr --overwrite=true
        
  4. Add labels to the custom resource definition, custom resource, subscription, and operator group of the License Service Reporter.

    oc label crd ibmlicenseservicereporters.operator.ibm.com foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    oc label ibmlicenseservicereporters.operator.ibm.com instance foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    oc label subscription ibm-license-service-reporter-operator foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    oc label operatorgroup operatorgroup foundationservices.cloudpak.ibm.com=lsr --overwrite=true
    

    Note: The command includes the default names for the resources. If error message is displayed, check the namespace of the License Service Reporter for the specific names of the subscription, operator group, and custom resource.

    oc get ibmlicenseservicereporters.operator.ibm.com
    

Back up persistent data of the License Service Reporter

  1. Get the backup resources of the License Service Reporter.

    wget https://raw.githubusercontent.com/IBM/ibm-common-service-operator/scripts/velero/schedule/license_service_reporter/lsr-backup-deployment.yaml
    wget https://raw.githubusercontent.com/IBM/ibm-common-service-operator/scripts/velero/schedule/license_service_reporter/lsr-backup-pvc.yaml
    wget https://raw.githubusercontent.com/IBM/ibm-common-service-operator/scripts/velero/schedule/license_service_reporter/lsr-br-scripts-cm.yaml
    wget https://raw.githubusercontent.com/IBM/ibm-common-service-operator/scripts/velero/schedule/license_service_reporter/lsr-sa.yaml
    wget https://raw.githubusercontent.com/IBM/ibm-common-service-operator/scripts/velero/schedule/license_service_reporter/lsr-role.yaml
    wget https://raw.githubusercontent.com/IBM/ibm-common-service-operator/scripts/velero/schedule/license_service_reporter/lsr-rolebinding.yaml
    
  2. Update the backup files.

    By default, the lsr-backup-pvc.yaml needs to replace the following parameters:

    • Replace <lsr namespace> with the namespace where the License Service Reporter instance is deployed.
    • Replace the <storage class> with the storage class of the current License Service Reporter.

      Replace <lsr namespace> with the namespace where the License Service Reporter instance is deployed in the lsr-backup-deployment.yaml file.

      By default, the backup and restore commands (represented by .spec.template.metadata.annotations.pre.hook.backup.velero.io/command & .spec.template.metadata.annotations.post.hook.restore.velero.io/command) are scheduled to run in the <lsr namespace> namespace as parameters to the scripts called in the commands. Edit both commands' first parameter values to match the namespace that the deployment is created in.

      By default, the restore command (represented by .spec.template.metadata.annotations.post.hook.restore.velero.io/command) is set to run against a License Service Reporter named <license service reporter name>. Update the second parameter to match the name of the License Service Reporter in the target namespace.

      In the lsr-br-scripts-cm.yaml and lsr-sa.yaml, make sure to replace the namespace value <lsr namespace> with the namespace where the License Service Reporter is deployed in use for each instance of the license service reporter in use.

  3. Add the PVC to the cluster.

    oc apply -f lsr-backup-pvc.yaml
    
  4. Add lsr-br-scripts-cm.yaml to the correct namespace.

    oc apply -f lsr-br-scripts-cm.yaml
    
  5. Give the License Service Reporter backup necessary permissions.

    1. Create a service account for each namespace with a License Service Reporter to back up. Replace the <lsr namespace> with the namespace where the License Service Reporter is deployed.

      oc apply -f lsr-sa.yaml
      
    2. Apply the Role for the License Service Reporter backup for each namespace where the License Service Reporter is deployed. Replace <lsr namespace> with the namespace where the License Service Reporter is deployed.

      oc apply -f lsr-role.yaml
      
    3. Create the RoleBinding to connect the ServiceAccount to the Role.

      1. Edit the lsr-rolebinding.yaml file to add the ServiceAccount created earlier and replace the <lsr namespace> value.

        vi lsr-rolebinding.yaml
        
        1. Apply the lsr-rolebinding.yaml file.

          oc apply -f lsr-rolebinding.yaml
          
  6. Add the deployment to the cluster.

    oc apply -f lsr-backup-deployment.yaml
    

Restore License Service Reporter instance and its data

  1. Restore the License Service Reporter instance.

    1. Replace __BACKUP_NAME__ with the name of the backup resource that you created in the backup process.

      vi restore-lsr.yaml
      
    2. Restore the License Service Reporter instance.

      oc apply -f restore-lsr.yaml
      
    3. Check restore progress.

      velero restore get
      
    4. Verify that the License Service Reporter namespace, subscription, operator group, secrets, and instance are restored.

      oc get namespace | grep <lsr namespace>
      oc get sub -n <lsr namespace>
      oc get operatorgroup -n <lsr namespace>
      oc get secrets -n <lsr namespace>
      oc get ibmlicenseservicereporters.operator.ibm.com -n <lsr namespace>
      oc get pods -n <lsr namespace>
      

      Note: It takes a few minutes to become ready. There are two pods in the <lsr namespace> namespace with operator and instance as its suffix. Proceed to the next step when the two pods are ready.

  2. Restore the License Service Reporter data.

    1. Replace __BACKUP_NAME__ with the name of the backup resource that you created in the backup process.

      vi restore-lsr-data.yaml
      
    2. Restore the License Service Reporter data.

      oc apply -f restore-lsr-data.yaml
      
    3. Check restore progress.

      velero restore get
      
    4. Check the logs of the velero restore to verify that the data is restored.

      velero restore logs restore-lsr-data