Link to home
Start Free TrialLog in
Avatar of Aaron Thorn
Aaron ThornFlag for United States of America

asked on

How to delete a list of backups after 14 days

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 ?

Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

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

Next


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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial