Use the Forfiles utility to delete old database backup files.
The Forfiles utility (forfiles.exe) comes installed with Windows Server 2003 and later. Forfiles enables batch processing of files. In conjunction with a SQL Server Agent job, you can use this utility to delete old database backup files to remove dependencies on items such as SQL Server maintenance plans, the xp_cmdshell extended stored procedure, or VBScript objects. For example, the following command uses Forfiles to delete all .bak files that are two days old or older in the E:\sqlbackup folder:
forfiles /p "e:\sqlbackup" /m "*.bak"
/c "cmd /c del /Q @path" /d -2
No comments:
Post a Comment