Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server 2008 - maint plan cleanup task not deleting old backup files

Posted on 2012-03-29
5
Medium Priority
?
2,589 Views
Last Modified: 2012-03-31
I have created a maintenance plan with only 1 task -- a cleanup task to delete all .bak files in the backup folder older than 1 week.  The job completes successfully and the log file entry says it ran successfully but it's not deleting the old files.  I have verified I have the file extension (.bak) and the backup folder correct.  There are .bak files in that folder much older than 1 week but they do not get deleted.  I checked the box that indicates to go 1 sub-folder below the one specified.  At my last job I setup the maint plan this way and it worked fine.

Ideas?
0
Comment
Question by:Eric3141
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Chris M
ID: 37786640
A maintenance plan always logs backup details in MSDB database so a plan will not delete old backup files which it did not backup initially.

For instance you have  maintenance plans:
"Plan A" and "plan B"
If both plans backup the same database and are also set to delete old backup files, "Plan A" will delete only old backup files which were logged as initially backed up by "Plan A".
Likewise, as much as both plans backup the same databases, "Plan B" will only clean-up old backup files which it originally backed up!

If you have a plan to delete old backup files but the backups were or are taken by another plan, then your plan will not work on them.
Similarly, if you have a maintenance plan which is meant to delete backup files for other plans, then it wont work too!
This is how SQL 2005, 2008 plans are made to work.

The solution is: You will have to manually delete the old backup files in the backup folder and then the current plan will delete its own backup files.

The logic used to work in SQL server 7 and SQL 2K .....but in 2K5, 2K, 2K8 R2 and 2012, this wont work.
0
 
LVL 52

Accepted Solution

by:
Vitor Montalvão earned 1500 total points
ID: 37787113
Try '*bak' or only '*' if you know that only backup files will be there.

Good luck
0
 
LVL 2

Author Comment

by:Eric3141
ID: 37787115
Thx.  That explains why maint plan B (that only has the task to delete old files) won't delete the old files.  But maint plan A (that backed up the databases) also has a task (in the same sub-plan where the backup happens) to delete old files -- and it's not doing that.  Plan A writes to a log file that one of the parameters is wrong or the connection string is wrong.  Yet the connection string (local system -- the default one) can't be wrong because the maint plan does actually backup the databases.  I don't see how the parameters can be wrong because I specified them thru the maint plan wizard.

Ideas?
0
 
LVL 2

Author Comment

by:Eric3141
ID: 37787899
Oh my gosh... for file extension I included the '.' so was using '.bak' instead of 'bak'.  So the maint plan job was looking for files with extension = '..bak' older than one week to delete.  Not finding any, the job completed normally without error and did not delete the old files.
0
 
LVL 12

Expert Comment

by:Chris M
ID: 37790911
Extension should be "BAK".
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question