SQL Maintenance Plan Doesn't Delete Backups

I recently created a maintenance plan for our server to backup all the databases on a daily basis.  In the cleanup step I set it to delete backups older than 7 day.  I let the plan run for a week and checked on it to make sure the old backups were being deleted.  This would be kind of a useless post if everything was working correctly, so as you guessed, they were not being deleted.  I check everything on the plan: Username, folder name, first level subfolders, permissions on the backup folder, sql server agent permissions.  You name it.  All to find out that my problem was in the maintenance plan all along.  The option for file extension was the issue.  I had entered .bak when I should have entered bak.  I was thinking hey, I set up a foreach loop to loop through text files I enter .txt so for backup files I should enter .bak: WRONG!  Once I changed this option from .bak to bak everything worked fine.  Now my maintenance plan backups and deletes everything older than a week!

About the author

Bradley Schacht

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Jacksonville, FL. Bradley is a former consultant, trainer, and has authored 5 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

18 comments

Leave a Reply to Andrew Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Bradley Schacht

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Jacksonville, FL. Bradley is a former consultant, trainer, and has authored 5 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

Follow Me