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

To back up the STAP database, 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. 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.
  3. Ensure that the backup is saved to a safe location on separate hardware from your implementation.
  4. Scale up TDS deployment:
    kubectl scale deployment tds-deployment  --replicas=1 -n namespace

Restoring the STAP Database

To restore an already deployed version of STAP, 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".