This script can be used to cleanup older snapshots in CAST AIP. Snapshots are cleaned up based on the retention criteria specified in the resources/AIPCleaner.yaml file.
The script is written in Python. Ensure that you have Python 3.6 or above installed. It uses the following Python packages. Ensure these are installed using the Python PIP command. PIP installs dependent packages, where needed.
- requests
- PyYAML
Refer to Installing Python Modules webpage for more information on how to install Python modules.
- Copy the files and folder into a folder named AIP_SnapshotCleaner.
- Create a blank folder named logs in the newly created folder.
- Edit the
AIPCleaner.YAML
file in the resources file and setup the retention criteria as needed. See for details.
At this time, the script support the following retention criterias:
- M - Retain monthly snapshots
- Q - Retain quarterly snapshots
- Y - Retain yearly snapshots
Setup the retention criteria as follows, for example, to retain monthly snapshots for the current year, quarterly snapshots for the prior year and yearly snapshots for the rest of the years.
retention_policy:
current_year: M
prev_year: Q
other_years: Y
Use the following option to ensure that the latest N number of snapshots are always kept:
keep_latest_n_snapshots: 5
Additionally, use the following option to retain baseline snapshots:
keep_baseline: true
Update the AAD URL, credentials, name and location of the CAST-MS PMX file, log folder location and CAST installation folder location.
The script deletes the snapshots that match the criteria specified, using the CAST-MS CLI command. This causes snapshots to be dropped from the dashboard service schema for each of the apps. So before running cleanup each time, ensure that the dashboard service schema is backed up.
The script can by running by invoking python and passing in the name of the script as an argument. Before starting, change directoy to move to the script folder.
python AIPSnapshotCleaner.py
- This will invoke the script in a display only mode, where it does not delete snapshots, but will display which snapshots will be dropped. To drop outdated snapshots, invoke the script with a -drop argument as in: python AIPSnapshotCleaner.py -drop
👉 NOTE: Ensure that the id being used for connecting to AAD (the username specified in the dashboard section in the YAML file) has admin rights to the HD dashboard. Else, some actions will fail.