Back Up and Restore a Domain on PV

Oracle recommends that you back up the domain home directory (and the JRF database for the JRF domain) after you have created the initial domain. You can then continue to take periodic backups, ensuring that all the latest changes are backed up.

You may update the domain on PV domain configuration after its initial deployment. For example, you may want to add new applications. However, after the update, the original WDT model files used to create the initial domain may not match the current state of the domain.

Oracle recommends that you periodically back up the domain home with the latest changes. The domain can be restored from the backup copy if you want to revert the changes made to the domain home directory. If the domain home is not properly backed up, there is a possibility of losing existing data if the domain home becomes corrupt or gets deleted.

Back Up the Domain

The back up procedure comprises the following steps:

Back Up the Domain Home Directory

You can use the following script to back up the domain home to the /u01/shared backup location. This script is available in the /u01/scripts/utils/backup.sh on the administration instance.
#!/bin/bash -x
if [ -z "$1" ]; then
  echo "Usage: backup.sh <domain_name>"
  exit 1
fi
 
domain_name=$1
timestamp=`date '+%Y-%m-%dT%T.%3N'`
domain_dir=/u01/shared/data/domains/$domain_name
domain_uid_dir=${domain_dir}-uid
 
backup_dir=/u01/shared/data/domains.backup/$domain_name/$timestamp/
mkdir -p $backup_dir
echo backup_dir: $backup_dir
 
echo "backing up $domain_dir"
cp -r $domain_dir $backup_dir
 
echo "backing up $domain_uid_dir"
cp -r $domain_uid_dir $backup_dir
 
echo "backup created: $timestamp"
Execute the script using the following command:
bash /u01/scripts/utils/backup.sh <domain_name>
This is an example of the output:
$ bash backup.sh pvdomain
backup_dir: /u01/shared/data/domains.backup/pvdomain/2023-12-04T18:53:24.381/
backing up /u01/shared/data/domains/pvdomain
backing up /u01/shared/data/domains/pvdomain-uid
backup created: 2023-12-04T18:53:24.381

The last line of the backup directory path is the backup timestamp (in the above example, it is 2023-12-04T18:53:24.381). The timestamp string is used to restore the backup. See Restore the Domain From the Backup.

Back Up the JRF Domain

A JRF domain has a one-to-one relationship with the RCU schema. After you create a domain using a particular RCU schema, you should back up the JRF database with the RCU schema and the associated wallet. For more information, see JRF Domains.

The back up procedure comprises the following steps:
Back Up the JRF Schema Database

After you create the JRF schema, create a backup of the JRF database. You can use the Oracle Database Backup Cloud Service or any database restore and back up method you prefer. For more information about Oracle Database Backup Cloud Service, see Getting Started with Oracle Database Backup Cloud Service.

Back Up the OPSS Wallet

After you create domain, the WebLogic Kubernetes Operator automatically exports the OPSS wallet and stores it in an introspector ConfigMap. The name of the ConfigMap follows this pattern: <domain uid>-weblogic-domain-introspect-cm with the key ewallet.p12. Save the OPSS wallet file in a safe, backed-up location immediately after the initial JRF domain gets created. This will allow the secret to be available when you want to recover the domain.

Execute the following commands on the administration instance:
mkdir -p /u01/shared/data/domains.backup/<domain>/
bash opss-wallet.sh -n <domain>-ns -d <domain>  -s -wf /u01/shared/data/domains.backup/<domain>/ewallet.p12
For example:
$ mkdir -p /u01/shared/data/domains.backup/pvdomain/
$ bash /u01/scripts/wls-domain-lifecycle/opss-wallet.sh -n pvdomain-ns -d pvdomain -s -wf /u01/shared/data/domains.backup/pvdomain/ewallet.p12
@@ Info: Running 'opss-wallet.sh'.
@@ Info: Saving wallet from from configmap 'pvjrf2-weblogic-domain-introspect-cm' in namespace 'pvjrf2-ns' to file '/u01/shared/data/domains.backup/pvdomain/ewallet.p12'.

Restore the Domain

The restore procedure comprises the following steps:

Restore the Domain From the Backup

To revert the domain updates, or to recover from the lost domain home directory, restore the domain from a backup copy of the domain home directory.

You can use the following script to restore the domain home from the backup location on /u01/shared. The script is available in the /u01/scripts/utils/restore.sh on the administration instance.
#!/bin/bash -x
if [[ -z $1 || -z $2 ]]; then
  echo "Usage: restore.sh <domain_name> <timestamp>"
  exit 1
fi
 
domain_name=$1
timestamp=$2
domain_dir=/u01/shared/data/domains/$domain_name
domain_uid_dir=${domain_dir}-uid
 
backup_dir=/u01/shared/data/domains.backup/$domain_name/$timestamp
backup_domain_dir=${backup_dir}/$domain_name
backup_domain_uid_dir=${backup_dir}/${domain_name}-uid
 
if ! [ -d ${backup_domain_dir} ]; then
   echo ${backup_domain_dir} not found !
   exit 2
fi
 
if ! [ -d ${backup_domain_uid_dir} ]; then
   echo ${backup_domain_uid_dir} not found !
   exit 3
fi
 
echo "Contents of the domain $domain_name at $domain_dir will be replaced by the backup contents at $backup_domain_dir"
echo "Contents of the domain $domain_name at $domain_uid_dir will be replaced by the backup contents at $backup_domain_uid_dir"
read -r -p "Continue? [y/N] " response
case "$response" in
    [yY][eE][sS]|[yY])
        :
        ;;
    *)
        echo "Aborting. No changes were done"
        exit 4
        ;;
esac
 
echo "restoring $domain_dir"
cp -r $backup_domain_dir $domain_dir
 
echo "restoring $domain_uid_dir"
cp -r $backup_domain_uid_dir $domain_uid_dir
 
echo "Domain Restored: $timestamp"
For example, to restore from the earlier backup that you created (see Back Up the Domain Home Directory), execute the script using the following command:
bash /u01/scripts/utils/restore.sh <domain_name> <backup_timestamp>
The output will be as follows:
$ bash restore.sh pvdomain 2023-12-04T18:53:24.381
 
Contents of the domain pvdomain at /u01/shared/data/domains/pvdomain will be replaced by the backup contents at /u01/shared/data/domains.backup/pvdomain/2023-12-04T18:53:24.381/pvdomain
Contents of the domain pvdomain at /u01/shared/data/domains/pvdomain-uid will be replaced by the backup contents at /u01/shared/data/domains.backup/pvdomain/2023-12-04T18:53:24.381/pvdomain-uid
Continue? [y/N] y
restoring /u01/shared/data/domains/pvdomain
restoring /u01/shared/data/domains/pvdomain-uid
Domain Restored: 2023-12-04T18:53:24.381

Restart the Domain After the Restore

After restoring the backup, you should restart the domain in a rolling manner.

  1. Execute the following command on the administration instance:
    bash /u01/scripts/wls-domain-lifecycle/rollDomain.sh -n <domain-namespace> -d <domain>
  2. Wait for all the server pods of the domain to terminate, and then restart the domain.
    For example:
    [opc@wlsoke-admin ~]$ bash /u01/scripts/wls-domain-lifecycle/rollDomain.sh -n pvdomain-ns -d pvdomain
    [2023-12-04T22:53:32.889498983Z][INFO] Patching restartVersion for domain 'pvdomain' to '2'.
    domain.weblogic.oracle/pvdomain patched
    [2023-12-04T22:53:34.763168023Z][INFO] Successfully patched restartVersion for domain 'pvdomain'!
    k get pods -n pvdomain-ns -w
    This is an example of the output:
    NAME                                READY   STATUS    RESTARTS   AGE
    pvdomain-pvdomain-adminserver       1/1     Running   0          4h17m
    pvdomain-pvdomain-managed-server1   1/1     Running   0          4h13m
    pvdomain-pvdomain-managed-server2   1/1     Running   0          4h10m