How to schedule a backup cleanup

disk-cleanupThis post is a continuation of a previous post where we explained how to do a maintenance plan which 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.

backup cleanup

backup cleanup

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 in our schedule, double-click the dropped task icon to set up its properties.

backup cleanup

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.

About Radu Gheorghiu

Passionate SQL Developer on the journey of trying to become an expert in all things Data (storage, manipulation, gathering etc.) Information is power, and information can only be obtained from data. Thus, in order to harness the power of information, you must be a master of Data.

Leave a Reply

Your email address will not be published. Required fields are marked *