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.
- In your TDS overrideValues.yaml file, set the restore enable flag to true.
- 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
- 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
- Ensure read write to db is disabled by scaling down TDS
deployment:
kubectl scale deployment tds-deployment --replicas=0 -n namespace - Navigate to the NFS/PV mount, and take a backup of the database folder.
- The following is an example script for creating backup
files:
Alternatively, use theecho "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"kubectl cpcommand 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. - Ensure that the backup is saved to a safe location on separate hardware from your implementation.
- 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
- 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. - 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 - Upgrade the helm chart for the TDS
microservice:
helm upgrade tdsHelmChart chartDirectory -n namespace -f override-values.yaml
- Verify the database has been restored with the TDS APIs. For more information, see REST API Reference for STAP.
Restoring the STAP Database Manually
- Uninstall the existing TDS microservice by running the following
command:
helm uninstall tds_chart_name -n namespace - Unzip or untar the previously backed up folder and move it to the NFS mount.
- Rename the folder to db in the root directory of the NFS mount.
- Re-install the TDS microservice. For more information see "Installing TDS".
Migrating Data to a New Environment
- Unzip or untar the previously backed up folder and move it to the NFS mount in the new setup.
- 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. - Install the TDS microservice. For more information, see "Installing TDS".