February 28, 2008 at 6:20 pm
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
February 28, 2008 at 6:52 pm
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.
MARCUS. Why dost thou laugh? It fits not with this hour.
TITUS. Why, I have not another tear to shed;
--Titus Andronicus, William Shakespeare
February 28, 2008 at 8:45 pm
It should work using maintenance plan - Maintenance Cleanup Task.
Refer to this post:
http://www.sqlservercentral.com/Forums/Topic432440-357-1.aspx#bm451969
February 29, 2008 at 7:16 am
Thanks for your Reply... I really appreciate all of you...
February 29, 2008 at 9:13 am
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
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply