We help IT Professionals succeed at work.

How to delete a  list of backups after 14 days

Aaron Thorn
Aaron Thorn used Ask the Experts™
I do backups every day    I want to delete them after 14 days   Would i have to create a scrip to do this or will sql do this for me ?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011

I used script to do mine - a very, very simple-minded script.

Just schedule it using windows task scheduler to schedule the delete every day.

Dim Fso

Dim Directory 

Dim Modified

Dim Files


Set Fso = CreateObject("Scripting.FileSystemObject")

Set Directory = Fso.GetFolder("E:\BACKUP")  'Replace with your backup directory

Set Files = Directory.Files

For Each Modified in Files

If DateDiff("D", Modified.DateLastModified, Now) > 14 Then Modified.Delete


'MsgBox "Completed Processing Files From: " & Directory & ""

Open in new window

Software Engineer

You can use SSMS to create a maintenace plan that will delete backup files

Expand Management, Right click on Maintenance Plans, and select New Maintenance Plan...

From the ToolBox,, select Maintnance Cleanup Task, drag it to your subplan, double click on it and select your prefered options