Home > database >  MSSQL2000, how to delete the old backup bak files?
MSSQL2000, how to delete the old backup bak files?

Time:09-16

"D: \ automatic backup database" in the directory below, with homework bak backup of the database backup file, for example:
A2020-06-01 _06-11. Bak
_06 a2020-06-11-11. Bak
A2020-06-21 _06-11. Bak
A2020-07-01 _06-11. Bak
_06 a2020-07-11-11. Bak
A2020-07-21 _06-11. Bak
A2020-07-31 _06-11. Bak

A2020-08-01 _06-11. Bak
A2020 _06-08-11-11. Bak
A2020-08-21 _06-11. Bak
A2020-08-31 _06-11. Bak
.
I want to write a homework, will be a month ago BAK backup file is automatically deleted (for example in September, will be in July and before. BAK delete), how?

CodePudding user response:

Get a bat or VBS file to perform on a regular basis

CodePudding user response:

Copy the code below, save for the bat file

@ echo off

: : demo: delete specified path under the specified number of days before (the file was last modified date shall prevail) files,

: : if the demonstration result is correct, the echo del front are removed, can be realized really deleted,

: : this case need Win2003/Vista/Windows 7 forfiles command support system at
Rem specified to delete the file storage path

The set DaysAgo=30

Automatic backup set SrcDir1=D: \ database
SrcDir1 forfiles/p % %/s/m * */c/d - % DaysAgo % "CMD/c del/f/q/a @ path"

CodePudding user response:

Essentially a new maintenance plan, you can choose to regularly delete directly, 5 steps can be completed, the operation is simple, new beginner worries:
1. Database instance, choose management, new maintenance plan wizard
2. Select the backup database, and set the next need to backup of the database Settings
3. Double-click has new maintenance plan, and, after the completion of open design window
4. On the left side of the "clear maintenance tasks in the options box, Settings,
5. After the completion of the removal of maintenance tasks, backup plans a green arrow link monitoring,
The diagram below:

CodePudding user response:

If it is SQL2000, consider to upgrade to the lowest SQL2005 (2000 set to compatible mode), improved performance,
  • Related