SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Delete Old backup Files


Delete Old backup Files

Author
Message
Shas3
Shas3
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1271 Visits: 48
Comments posted to this topic are about the item Delete Old backup Files

Shas3
h2sut
h2sut
SSC-Enthusiastic
SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)

Group: General Forum Members
Points: 123 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.
karuanag
karuanag
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 3
As the other poster asked some instructions on running this would be grand!

Thanx in advance

Karuana
Lizzy Gradidge
Lizzy Gradidge
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 112
Thanks this worked brilliantly for me . It has saved me much time and I now understand a bit more about vbs. Smile

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
Lizzy Gradidge
Lizzy Gradidge
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 112
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
logicinside22
logicinside22
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5517 Visits: 1463
DOes it works with sql server 2008R2?

Aim to inspire rather than to teach.
SQL Server DBA
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search