published

cisco_dna_backup_cleaner.sh

Cisco DNA Center is able to create scheduled system backups, but there's not way to remove old backups, hence deleting should be done manually from DNA-C. Pretty annoying...
I wrote this Bash script to automatically removing old backups basing on a retention period.

This script runs on GNU and require "curl" and "jq" packets installed to working properly. Is intended to run from the path ~/script, but of course it can be changed.

Edit the script to change the URLs pointing to the hostname of your DNA-C installation. Please, use cluster URL in case of 3 nodes deployment.
Change also the base64 autorization key (currently ABC123= as placeholder), matching with your username and password used on DNA-C. Use a tool like https://www.base64encode.net/ for the encoding.

Change also the RETENTION value in order to match your needs.

In my case, I scheduled the backups from DNA-C at Friday 9pm and the script runs from crontab at 11.30pm:

30 23 * * 5 /bin/bash /PATH_TO/scripts/cisco_dna_backup_cleaner.sh >/dev/null 2>&1

Screenshot of a run:
Screenshot of a run

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.