This post is a continuation of a previous post where we explained how to do a maintenance plan that will take care of creating backups via a schedule.
Now that we have a schedule that consistently creates backups, we might want to create a backup cleanup schedule to remove older backup files.
Scheduling backup cleanup via SSMS
Continuing where we left off on our previous article where we used to create a maintenance plan for backing up our databases, we will use the last step where we stopped as a starting point for this article.
It is not mandatory to have a backup plan set up in order to have a cleanup plan, but it is good practice to do the cleanup at the same time when you’re doing your backup, so you do not forget to do it separately.
So, in order to create the cleanup plan, in the same window we left off we’re going to go in the highlighted bottom left side of the screen and drag and drop a Maintenance Cleanup Task.
You can set up only the Maintenance Cleanup Task by itself in the Maintenance Plan. Go to our other post to see how to create a Maintenance Plan if you need help.
Now that we have our Cleanup Task integrated into our schedule, double-click the dropped task icon to set up its properties.
Choose what type of files to remove with this task or a specific file if your backup is always named the same. Otherwise, you can choose the folder in which to look for these files and delete them all. Set up their extension and the age limit in order to filter the files that are going to be removed.
When everything is set up, just press OK. Save the maintenance plan and either wait for the next execution time to see if it works or run it manually to see if it is in order.