Tuesday, 3 February 2009

Delete SQL backup files over X days old.

Put this in a batch file and schedule it!

FORFILES /p C:\!DB_BACKUP_TEMP /s /m *.BAK /d -7 /c “CMD /C del /Q @FILE”

Careful copying the above command, the double quotes mess it up! copy into notepad, retype the double quotes, then it will be fine!

Note the -7 for 7 days.

http://thebackroomtech.com/2007/12/07/howto-automatically-remove-files-older-than-%e2%80%98x%e2%80%99-days-part-ii/

No comments: