9 Backing Up And Restoring the STAP Database

Learn how to backup and restore the Oracle Communications Solution Test Automation Platform (STAP) database.

Backing Up the STAP Database

You can either automate the STAP database's backup script, or perform the backup manually. To automate the backup script, see "Automating the STAP Backup Scripts". To manually backup the STAP database, see "Backing Up the STAP Database Manually".

Automating the STAP Backup Scripts

When you automate the STAP backup scripts, the script scales down the TDS deployment, creates a backup, and scales up the TDS deployment when the backup is complete.

To automate the STAP backup scripts:
  1. In your TDS overrideValues.yaml file, set the restore enable flag to true.
  2. Run the following command script in the path tdaas/cntk/scripts:
    sh tdaas-backup.sh namespace -n helmRelease chartPath overrideValuesPath
    where:
    • helmRelease is the name of the TDS helm chart
    • chartPath is the path to the TDS helm chart
    • overrideValuesPath is the path to the override values yaml file for the TDS helm chart
  3. Verify that the backup .tar.gz file was created in the backups folder on the NFS/PV mount.

    Note:

    This is an offline backup. TDS pod will be unavailable when the backup script is running.

Backing Up the STAP Database Manually

To back up the STAP database manually, follow these steps:
  1. Ensure read write to db is disabled by scaling down TDS deployment:
    kubectl scale deployment tds-deployment  --replicas=0 -n namespace
  2. Navigate to the NFS/PV mount, and take a backup of the database folder.
  3. The following is an example script for creating backup files:
    echo "Creating backups folder if not exists..."
    mkdir -p backups
    echo "Deleting old backup archives..."
    rm -rf ./backups/*.tar.gz
    TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
    BACKUP_DIR="./backups/db_bkp_$TIMESTAMP"
    echo "Creating new backup at $BACKUP_DIR..."
    mkdir -p $BACKUP_DIR
    cp -r db $BACKUP_DIR
    echo "Compressing backup..."
    tar -czf "$BACKUP_DIR.tar.gz" -C ./backups "db_bkp_$TIMESTAMP"
    echo "Removing uncompressed backup folder..."
    rm -rf $BACKUP_DIR
    echo "Backup completed: $BACKUP_DIR.tar.gz"
    Alternatively, use the kubectl cp command to backup the /data/db folder from the TDS pod. For more information, see the Kubernetes documentation:

    https://kubernetes.io/docs/reference/kubectl/generated/kubectl_cp/

    Note:

    To access the NFS/PV or pod files, you must have administrator access.
  4. Ensure that the backup is saved to a safe location on separate hardware from your implementation.
  5. Scale up TDS deployment:
    kubectl scale deployment tds-deployment  --replicas=1 -n namespace

Restoring the STAP Database

You can either automate the STAP database's restoration process, or restore the database manually. To automate the process, see "Automating the Restoration Process". To restore the STAP database manually, see "Restoring the STAP Database Manually".

Automating the Restoration Process

To restore an already deployed version of STAP:
  1. Move the previously backed up tdaas-backup.tar.gz folder to the NFS mount. Alternatively, you can also move it to the directory /data/db in the pod. Ensure the directory is empty by removing any existing files.

    Note:

    If you are using a remote path, ensure it is accessible from the cluster.
  2. In your TDS overrideValues.yaml file, set the restore flag to true, and enter the path to the tdaas-backup.tar.gz folder:
    restore: true
    backupFilePath: /data/db/tdaas-backup.tar.gz
  3. Upgrade the helm chart for the TDS microservice:
    helm upgrade tdsHelmChart chartDirectory -n namespace -f override-values.yaml
  4. Verify the database has been restored with the TDS APIs. For more information, see REST API Reference for STAP.

Restoring the STAP Database Manually

To restore an already deployed version of STAP manually, roll back the database to the last backed up version by following these steps:
  1. Uninstall the existing TDS microservice by running the following command:
    helm uninstall tds_chart_name -n namespace
  2. Unzip or untar the previously backed up folder and move it to the NFS mount.
  3. Rename the folder to db in the root directory of the NFS mount.
  4. Re-install the TDS microservice. For more information see "Installing TDS".

Migrating Data to a New Environment

If you are setting up a new STAP environment, and want to migrate your data from the old setup, follow these steps:
  1. Unzip or untar the previously backed up folder and move it to the NFS mount in the new setup.
  2. Rename the folder to db in the root directory of the NFS mount.

    Caution:

    The NFS database folder should be exclusively allocated and used by only one TDS microservice at a single point in time.
  3. Install the TDS microservice. For more information, see "Installing TDS".