Introduction
This guide details the configuration of a .BAT file with Windows Task Scheduler so that database
backup files (such as multiMAX.bak, multiMAXTxn.bak and multiMAXTxnOps.bak) are automatically
deleted after a pre-determined amount of days.
.BAT File Creation
The following line can be used in a .BAT file (.BAT files can be created by adding the following line in
Notepad and saving the file as .BAT):
Forfiles /m *.bak /d -4 /c “cmd /c del @file”
To understand what this is doing:
- Forfiles – this is the application which is performing the delete; this should be present by default
on Windows Vista, 7, Server 2003 and Server 2008. It is available for Windows XP but needs to be
downloaded manually from Microsoft’s website. - /m *.bak – this applies a mask so only *.BAK files will be deleted (the backup files) from the folder
that the .BAT is stored in. - /d – 4 – if the file has not been modified for four days it will be removed, this can be changed to the amount of days required by amending the number (files newer than this will not be deleted).
- /c “cmd /c del @file” – this is the Command Prompt line that deletes @file (which is *.BAK).
Automated Run of the .BAT File
Once a .BAT file has been created, place it into the folder where backups are being saved into.
The Windows Task Scheduler (Start | System Tools | Task Scheduler) can then be used to
automatically run the file. To do this:
- Open Task Scheduler and create a ‘Basic Task’.
- Name the Task and locate the .BAT file.
- Select the date/days that the .BAT file needs to be run on, in this example, if the batch file is run
every day it will remove the fourth days .BAK file each day.
In addition...
If you require the crf.ini and multimax.ini backup files to be removed as well, a second .BAT can be
created containing the mask /m *.ini instead. Creating another Task using the Scheduler will make
sure it is automatically deleted.
NOTE: Please make sure no other important .BAK or .INI files are held in the place where the backup files are being deleted from as these will also be removed.
Comments
0 comments
Please sign in to leave a comment.