SQL Server Performance Forum – Threads Archive
How to remove Old Backup FilesHi..
I am new to Database Administration.. and I am stuck on one task. . deleting old back up files.. I am going to do back up on month end and i need to remove those month end backup after 2-3 days through SQL jobs.
I was looking for the script which does cleaning the backup and I found that XP_DELETE_FILE does that. but found that, this is an undocumented command and didn’t get any help on that. could some one please give me script for this. what I need is, to delete Backup file "abcde_03_07.bak" from "f:ackupmonthend" directory. thanks.
You can use XP-DELETE_FILE even it is undocumented becuase it is used in Maintenance plans to clean old bakcup jobs…
You can use the following… exec xp-cmdshell ‘dele <filename with path>’ MohammedU.
SQL-Server-Performance.com All postings are provided â€œAS ISâ€ with no warranties for accuracy.
Did I understand correctly? You get backups once in a month and you delete the previous month? What about transaction logs? Do you generate them at least one per day? CanadaDBA
In any case you can take help of database maintenance plans to drop the older backups in this case, as suggested you need to be careful when using undocumented SPs. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.