-
Notifications
You must be signed in to change notification settings - Fork 106
Description
I get hourly backups working OK using the cron, but I want to only keep 24hrs of backups (1 days) and then delete the oldest. At the moment, the backup works great, but the rotation does not delete anything - even though I specified 1 day:
CONFIG_rotation_daily='1'
Any ideas?
I tried for several days to write some modifications (below) to delete the oldest backups, but I am not expert enough and I can't get it working.
`####Retention period for daily backups in the MYSQL_backups folder
SERVER_RETENTION_DAYS=1####Function to delete old server backups based on retention period
delete_old_server_files() {
log_message "Cleaning up server-side backups older than $SERVER_RETENTION_DAYS days..."
find "/home/$CPANEL_USERNAME/MYSQL_backups/$BACKUP_SUBDIR" -type f -name "*.sql.gz" -mtime +$((SERVER_RETENTION_DAYS)) -exec rm -f {} ;
log_message "Old server-side backups older than $SERVER_RETENTION_DAYS days have been deleted."
}`