Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Delete Old backup Files Expand / Collapse
Author
Message
Posted Monday, October 01, 2007 8:32 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, December 19, 2012 10:42 AM
Points: 319, Visits: 47
Comments posted to this topic are about the item Delete Old backup Files

Shas3
Post #405353
Posted Wednesday, December 19, 2007 9:44 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, May 13, 2010 12:54 PM
Points: 11, Visits: 55
Hello I was wondering how do you execute that statement. I saw that you said it was a vb script. So in my sql 05 database i would have to call that script or could i hard code it in the database. If so could you give detail insturctions.
Post #434842
Posted Tuesday, July 29, 2008 5:16 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 06, 2009 2:29 PM
Points: 3, Visits: 3
As the other poster asked some instructions on running this would be grand!

Thanx in advance

Karuana
Post #543131
Posted Thursday, August 14, 2008 10:01 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, September 09, 2013 2:41 AM
Points: 16, Visits: 110
Thanks this worked brilliantly for me . It has saved me much time and I now understand a bit more about vbs. :)

I have put this script into the last job step on my backup job in sql2005 .
select type as activeXscript and language vb script and it runs !

Lovely job


Thanks again
Lizzy
Post #552871
Posted Tuesday, September 16, 2008 4:29 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, September 09, 2013 2:41 AM
Points: 16, Visits: 110
Ahhhh after running this successfully for a month from 14/08/2008 I discovered a blip when the day changes from 9 th to the 10th (Discovered this on the 9/11/2008 which spooked me a bit ) The DateCheck function can not handle the extra digit on the expiration num and deletes the new files rather than the old files. However this is inconsistant as the results from my log file show:

-----------------------------------------------

YToday num =2008
MToday num =9
DToday num 15
YExpiration num = 2008
MExpiration num = 9
DExpiration num =14
lastmodified num = 200899
Expiration Num =2008914
DateCheck new

YToday num = 2008
MToday num = 9
DToday num =15
YExpiration num =2008
MExpiration num = 9
DExpiration num =14
lastmodified num =200888
Expiration Num = 2008914
database deleted = mydatabase_db_200808081830.bak,8/8/2008 6:30:02 PM
-------------------------------------


LastmodifiedNum < ExpirationNum
Why Then is 200888 < 2008914 correct but 200899 < 2008914 is not correct ?


I have amended the function to use DateDiff this is working well so far.

Function DateCheck(Lastmodified)
DiffADate = DateDiff("d", Lastmodified,Date )
LogFile.Writeline "Date difference = " & " " & DiffADate

If DiffADate > Days then
DateCheck="old"
LogFile.Writeline "DateCheck " & "" & DateCheck
else
DateCheck="new"
LogFile.Writeline "DateCheck " & "" & DateCheck
end if
end Function

Will keep you posted of my progress.
Cheers
Lizzy
Post #570064
Posted Monday, January 16, 2012 9:25 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: 2 days ago @ 1:05 PM
Points: 304, Visits: 1,171
DOes it works with sql server 2008R2?

Aim to inspire rather than to teach.
SQL Server DBA
Post #1236692
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse