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


Urgent:VB Script to delete 2-days old backup automatically


Urgent:VB Script to delete 2-days old backup automatically

Author
Message
K-SQL-SSC
K-SQL-SSC
SSC Veteran
SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)

Group: General Forum Members
Points: 241 Visits: 63
Hi All,

I have to develope an automation task in SQL server 2005 which can delete 2-days old backup from Netwok drive automatically. It is possible with vb script. But I don't know how to implement it in to the Production server. So, if some body help me in this issue. I want a vb script and stepwise procedure to implement it. I need to create a Job or maintenace plan in SQL Server 2005 ? I have to delete older back up in network drive so, how can i give the path. Please help me.

I will really appreciate all of you. Looking for your reply...urgent please...

Regards,

KP
thecosmictrickster@gmail.com
thecosmictrickster@gmail.com
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4754 Visits: 940
Attached is a script I was using for a while (drop the .txt extension when you implement it, natch). You can either create a scheduled task in the Windows Task Scheduler or you can create a SQL Agent job with the following CmdExec command:

cscript "c:\scripts\DeleteFiles.vbs" //b //nologo

Just make sure the account that the SQL Agent runs under has rights to the folders in question (the folder the script is in as well as the folder the files to delete are in).

As for the script, you can specify as many folders as you want. You can specify the maximum age of any files in those folders - anything older will be deleted (look for intMaxAge).

Note - this script will look at ALL files in the folder, not just .bak files. I had things sorted into subfolders, so I could afford to be a bit lazy with the script in that respect.

Test it first to get the parameters to what you want them to be. Be aware that the files will be deleted, not moved to the recycle bin. There is no undo.



Scott Duncan

MARCUS. Why dost thou laugh? It fits not with this hour.
TITUS. Why, I have not another tear to shed;
--Titus Andronicus, William Shakespeare

Attachments
DeleteOldFiles.vbs.txt (100 views, 1.00 KB)
Vivien Xing
Vivien Xing
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3724 Visits: 2204
It should work using maintenance plan - Maintenance Cleanup Task.

Refer to this post:
http://www.sqlservercentral.com/Forums/Topic432440-357-1.aspx#bm451969
K-SQL-SSC
K-SQL-SSC
SSC Veteran
SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)

Group: General Forum Members
Points: 241 Visits: 63
Thanks for your Reply... I really appreciate all of you...
Sugesh Kumar
Sugesh Kumar
SSCrazy Eights
SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)

Group: General Forum Members
Points: 8717 Visits: 358
You have a backup delete task in SSIS which can be used to specify the location where the backup files reside. Why can't you use that.

Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
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