Skip to main content

Command Palette

Search for a command to run...

SQL Maintenance Plan Doesn't Delete Backups

Updated
1 min read
SQL Maintenance Plan Doesn't Delete Backups
B

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Saint Augustine, FL. Bradley is a former consultant, trainer, and has coauthored 6 SQL Server and Power BI books, most recently Learn Microsoft Fabric. 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. Bradley gives back to the community through speaking at events such as the SQLBits, Fabric Community Conference, PASS Community Data Summit, SQL Saturdays, Code Camps, and user groups across the country including locally at the Jacksonville SQL Server User Group (JSSUG). He is a contributor on SQLServerCentral.com and blogs on his personal site, BradleySchacht.com.

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!

1 views

More from this blog

B

Bradley Schacht - Development

172 posts

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Saint Augustine, FL.