July 22, 2008 at 11:19 am
Is there a way that I can set SQL Server to automatically delete backups that are older than X number of days? I have maintenance plans set up. I see this option in SQL Server 2000, but not in 2005. Any ideas?
July 22, 2008 at 2:41 pm
It's there, but not as an option. If you are setting up a Maintenance Plan in 2005 you have to setup a Maintenance Cleanup Task.
This provides the ability to delete files older that x minutes, hours, days, months, and years from a directory with a specific extension. This can be included with an existing maintenance plan or be created as a completely separate item.
Regards, Irish
July 22, 2008 at 2:57 pm
OK. Thanks.
July 23, 2008 at 1:10 am
If you are using native SQL 2005 backups (*.bak) then you can couple this piece of code to the end or beginning of your maintenance plan.
EXECUTE master.dbo.xp_delete_file 0,N'FILEPATH',N'BAK',CLEANUPDATE,1
FILEPATH refers to the location of the backup filesCLEANUPDATE> refers to the oldest ackups that should be kept. Any backup older than this date\time will be deleted
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply