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 Senior Program Manager on the Microsoft Azure Synapse Analytics team based in Jacksonville, FL. He has worked with Microsoft SQL Server and Azure data services since 2009 as a consultant, trainer, and architect. He has co-authored 4 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. Bradley enjoys solving interesting problems and teaching others to use new technology. 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

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

Bradley Schacht

Bradley Schacht is a Senior Program Manager on the Microsoft Azure Synapse Analytics team based in Jacksonville, FL. He has worked with Microsoft SQL Server and Azure data services since 2009 as a consultant, trainer, and architect. He has co-authored 4 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. Bradley enjoys solving interesting problems and teaching others to use new technology. 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