Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to delete backup files after n days ?

Author  Topic 

hdv212
Posting Yak Master

140 Posts

Posted - 2010-05-10 : 12:19:12
Hi
we have a job to create backup every night.
how to delete backup files after n days automatically ?
is expire date suitable for this case ?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-10 : 12:50:55
Is the job using custom code or a maintenance plan? If it's a maintenance plan, then you should configure that option in the plan.

If it's custom code, then you can grab the delete code from my custom backup stored procedure (or better yet, just use this stored procedure in place of what you are using): http://weblogs.sqlteam.com/tarad/archive/2009/12/29/Backup-SQL-Server-2005-and-2008-DatabasesAgain.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-10 : 12:53:29
By the way, my delete code uses the file's create date/time to determine what needs to be deleted.

The delete code starts at line 325.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hdv212
Posting Yak Master

140 Posts

Posted - 2010-05-10 : 16:44:06
thanks Tara
but is there any to do this action via sql server standard features ?
via maintenance tasks or setting expire date ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-10 : 17:05:17
http://www.mssqltips.com/tip.asp?tip=1094

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -