Friday, 29 July 2016

Older SQL Backup files deletion through batch

To keep backup files up to 30 days and delete rest of the files in Windows Batch:

Create a batch file using the below command:

forfiles /M *.bak /P "Backup Folder" /S /D -NoOfDays /C "cmd /c del /F /Q @path"

forfiles /M *.bak /P "E:\SQL Backup" /S /D -30 /C "cmd /c del /F /Q @path"

Copy paste the below command in notepad and change your folder path and Days then Save as .bak file.

Refer below link for further:

Use the Windows Task Scheduler to call the batch script:

No comments:

Post a Comment