This repository provides a script and cron job configuration to automate the cleanup of old backups on a Cisco DNA Backup Ubuntu server.
You will find two scripts in this repository: preview_delete_files.sh
and delete_files.sh
. The preview_delete_files.sh
script allows you to preview which files would be deleted without actually removing them, ensuring that the correct files are selected. Once you are satisfied with the results, you can use delete_files.sh
to permanently delete the files. The cron job performs the same action as delete_files.sh
. If you are satisfied with the preview results, you can set up the cron job from the "Quick Cron Job Setup" for automatic cleanup.
To directly create a cron job that performs the cleanup task, run:
crontab -e
Then add the following line to schedule the cleanup script to run daily at 12:00 PM:
0 12 * * * find /mnt/automation/cluster1/*/ -maxdepth 1 -mindepth 1 -mtime +30 -exec rm -rf {} + >> /var/log/cisco-dna-backup-cleanup.log 2>&1
git clone https://github.com/Ch4r0ne/Cisco-DNA-Backup-Cleanup-Skript.git
cd Cisco-DNA-Backup-Cleanup-Skript
Cisco DNA Backup Directory
BACKUP_DIR="/mnt/automation/cluster1"
Adjust the value to the desired duration in days
DAYS="+30"
Make the scripts executable:
chmod +x preview_delete_files.sh
Edit the crontab file to schedule the cleanup job. Run:
crontab -e
Add the following line to schedule the script to run daily at 12:00 PM:
0 12 * * * /path/to/your/delete_files.sh >> /var/log/cisco-dna-backup-cleanup.log 2>&1
Ensure the cron job is scheduled correctly:
crontab -l
In the Cisco DNA web interface you will see that the backup disappears after a short time.
If you encounter any issues or have questions, please open an issue in this repository.
Note: Adjust the backup directory path and cron job schedule as needed to fit your environment.