Backing up Planning Analytics

A Planning Analytics administrator can use the Planning Analytics administration console to create an online backup.

Before you begin

  • Verify that the workstation where you run the installation is set up as a client workstation and includes the Red Hat® OpenShift® CLI.
  • Make sure that you are using the external version of the TM1 service. Export and import jobs for Planning Analytics support only the internal version of TM1.

    To determine if your TM1 service is external or internal, run the following command:

    oc get PAServiceInstance ${SERVICE_NAME} -n zen -o jsonpath='{.spec.tm1_internal_type}'

    If this command displays false as the output, your TM1 service is external.

Procedure

  1. Make sure that you are logged in to the Red Hat OpenShift cluster with the oc command line tool.
  2. Create the backup-pa.sh script to back up the instance.

    The backup-pa.sh script is a file with the following contents:

    #!/usr/bin/env bash
    #
    #       Licensed Materials - Property of IBM
    #
    #       IBM Cognos Products: pa
    #
    #       (C) Copyright IBM Corp. 2022
    #
    #       US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
    # -----------------------------------------------------------------------------
    #
    set +x
    
    PA_NAMESPACE=${1:zen}
    
    BACKUP_DATE_FORMAT="${BACKUP_DATE_FORMAT:-%Y_%m_%d_%H_%M_%S}"
    DATE=$(date +"${BACKUP_DATE_FORMAT}")
    BACKUP_DIRECTORY=./backup-${DATE}
    
    PA_COUCHDB_POD=""
    PA_MONGO_POD=""
    PA_MYSQL_POD=""
    PA_MYSQL_POD_1=""
    PA_MYSQL_POD_2=""
    PA_REDIS_POD=""
    
    KUBERNETES_CMD=oc
    
    
    function _getPod {
      local idx=0
      local maxIdx=0	
      local pod=''
      local pods=()
      local result=''
      local container=''
      
      pod="${1}${PAW_INSTANCE_ID}"
      container="${2}"
      
      if ! read -r -a pods <<< "$( ${KUBERNETES_CMD} get pods -o=jsonpath='{range .items[*]}{.metadata.name}{.name}{" "}{end}' -l name="${pod}" -n "${PA_NAMESPACE}" 2>&1 )"; then
        exit "${pods[@]}"
      fi
    
      if [ "${#pods[@]}" != "1" ]; then
        exit "${pods[@]}"
      fi
      
      maxIdx=${MAX_TIME:-30}
      while [ "${idx}" -lt "${maxIdx}" ]; do
    	result=$( ${KUBERNETES_CMD} exec "${pods[0]}" -c "${container}" -n "${PA_NAMESPACE}" -- /bin/bash -c 'ls >& /dev/null' 2>&1 )
        if [[ "${result}" != *"container not found"* ]]; then
    	  break
        fi
        sleep 1
        (( idx=idx+1 ))
      done
    
      if [ "${idx}" -eq "${maxIdx}" ]; then
        exit "$( _getMessage MSG_CONTAINER_NOT_FOUND "${container}" )"
      fi
        
      echo "${pods[0]}"
    }
    
    function _getPods {
      PA_COUCHDB_POD=$( _getPod 'couchdb-data1' 'couchdb1-data1' )
      PA_MONGO_POD=$( _getPod 'mongo-data1' 'mongo-data1' )
      PA_MYSQL_POD=$( _getPod 'mysql-server' 'mysql-server' )
      PA_MYSQL_POD_1=$( _getPod 'mysql-server1' 'mysql-server1' )
      PA_MYSQL_POD_2=$( _getPod 'mysql-server2' 'mysql-server2' )
      PA_REDIS_POD=$( _getPod 'redis-data1' 'redis-data1' )
    }
    
    function _flushMySQLHost {
      local result=''
      
      if ! result=$( ${KUBERNETES_CMD} exec "${1}" -c "${2}" -n "${PA_NAMESPACE}" -- /bin/bash -c "/tools/flush-hosts.sh" 2>&1 ); then
        exit "${result}"
      fi  
    }
    
    function _flushMySQLHosts {
      _flushMySQLHost "${PA_MYSQL_POD}" "mysql-server"
      _flushMySQLHost "${PA_MYSQL_POD_1}" "mysql-server1"
      _flushMySQLHost "${PA_MYSQL_POD_2}" "mysql-server2"    
    }
    
    function _backupDatabase {
      local result=''
    
      result=$( ${KUBERNETES_CMD} exec "${2}" -c "${3}" -n "${PA_NAMESPACE}" -- /bin/bash -c "/tools/backup.sh" 2>&1 )
    
      if ! result=$( ${KUBERNETES_CMD} cp "${PA_NAMESPACE}/${2}:/tmp/${1}.tgz" "${BACKUP_DIRECTORY}/${1}.tgz" -c "${3}" 2>&1 ); then
        exit "${result}"
      fi
    
      if ! result=$( ${KUBERNETES_CMD} exec "${2}" -c "${3}" -n "${PA_NAMESPACE}" -- /bin/bash -c "rm /tmp/${1}.tgz" 2>&1 ); then
        exit "${result}"
      fi
    }
    
    
    _getPods
    _backupDatabase couchdb "${PA_COUCHDB_POD}" couchdb-data1
    _flushMySQLHosts
    _backupDatabase mongo "${PA_MONGO_POD}" mongo-data1
    _backupDatabase mysql "${PA_MYSQL_POD}" mysql-server
    _backupDatabase redis "${PA_REDIS_POD}" redis-data1
  3. Run the backup-pa.sh script with the namespace where Planning Analytics is running as the argument.
    ./backup-pa.sh <pa_namespace>
  4. This script creates a folder that is named backup-${DATE}x in the current directory and contains the Planning Analytics instance backup.