Restoring your environment

Each environment in your disaster recovery plan contains different components to be restored.

About this task

You must prepare the environment that you want to use to restore your deployments with the backed-up data. To back up your data, see Backing up your environment.

Procedure

  1. Prepare the environment that you want to use to restore your deployments with the backed-up data.
    1. Install Red Hat OpenShift with the same version as your source environment. To install, see Installing Red Hat software.
    2. Install the FNCM operator by following the steps in Preparing your cluster to prepare and set up your environment.
  2. Create a project with the same name as your previous environment.
  3. Create the secure definition by using the backup secure definitions.
  4. Restore the persistent volumes (PV) and persistent volume claims (PVC):
    • If you are using static provisioning, restore your PVCs and PVs by using your backup definitions.
    • If you are using dynamic provisioning, create the PVC for cpe-filestore, icn-cfgstore, and css-indexstore.
  5. If you previously used Lightweight Directory Access Protocol (LDAP), restore the LDAP server. Different types of LDAP servers have different methods for restoring. For IBM Security Directory Server, see IBM Security Directory Server backup and restore. If you took a snapshot of the LDAP virtual machine in your previous environment, restore the snapshot.
  6. Restore all the databases from the backup images. For example, if you are using PostgreSQL, restore the data by using the database command pg_restore. If you are using Db2 with online backup, you can restore your databases by using the following commands:
     db2 restore database  OSDB  from '/home/db2inst1/backup/560/online' taken at 20211213191010 into  OSDB  replace existing 
    db2 restore database  GCDDB  from '/home/db2inst1/backup/560/online' taken at 20211213191016 into  GCDDB  replace existing 
    db2 restore database  ICNDB  from '/home/db2inst1/backup/560/online' taken at 20211213191024 into  ICNDB  replace existing  
     
    db2 rollforward db OSDB to end of logs and stop 
    db2 rollforward db GCDDB to end of logs and stop 
    db2 rollforward db ICNDB to end of logs and stop 
  7. Restore the files stored on the PV. Keep the same folder structure, the same user group information, and the same permissions.
    If you are using an NFS based storage, you can use the following script to restore PV content for PVCs such as cpe-filestore, css-indexstore and icn-cfgstore. The script does not restore log files. If you want to restore the log files, you need to copy the log files to the corresponding PV.
    #!/bin/sh 
     
    NS=fncm 
    SOURCE_DIR=/home/pv/560 
    TARGET_DIR=/home/pv/560 
    BACKUP_DIR=/home/backup 
     
    pvrestore() { 
        oc get pvc -n $NS --no-headers=true | while read each
        do
            pvc=`echo $each | awk '{ print $1 }'`
            pv=`echo $each | awk '{ print $3 }'`
               
            case $pvc in
                *"cpe-filestore"*)  echo "restore $pvc" ;;
                *"icn-cfgstore"*)  echo "restore $pvc" ;;
                *) continue ;;
            esac
            if [  -d "$BACKUP_DIR/$pvc" ]
            then
               echo "    cp -r -a $BACKUP_DIR/$pvc/.  $TARGET_DIR/$NS-$pvc-$pv/ "
               cp -r -a $BACKUP_DIR/$pvc/*  $TARGET_DIR/$NS-$pvc-$pv/
            else
               echo "NOT FOUND for $pvc"
            fi
        done
    } 
     
    pvrestore 
  8. If you are using an NFS based storage, modify the ownership of the files that you restored in step 7.
    1. Check the ownership of the backup files, by running a command similar to:
      drwxr-x--- 3 1000650000 root    4096 Dec 13 18:13 fncm-cpe-filestore 
    2. In your previous environment, check the uid-range in the namespace, by running the command:
      oc describe project fncm
      The output looks similar to:
      Name:                   fncm 
      Created:                20 hours ago 
      ... 
      Annotations:            ... ... 
                              openshift.io/sa.scc.supplemental-groups= 1000640000/10000 
                                    openshift.io/sa.scc.uid-range= 1000640000/10000 
    3. For all restored files, modify the uid from 100065000 to 100064000, by using the following command:
      find ./  -uid  1000650000  -exec chown 1000640000:root {} \; 
  9. Prepare the custom resource (CR) definition for the restored environment.
    1. If the previous environment's hostname is different than the restored environment's hostname, change the hostname in the CR files to match the hostname of the restored environment.
    2. If initialization was completed in the original deployment, set the following values in your CR to avoid reinitialization and verification that might cause an error in your database data:
      shared_configuration.sc_content_initialization: false
      shared_configuration.sc_content_verification: false
  10. Deploy the environment with the backup CR definition files.