JSI Tip 3330. How can I keep xx days worth of NTBackup log on Windows 2000?


The Windows 2000 NTBackup program keep 10 versions of the NTBackup log, named Backup01.log through Backup10.log. These logs are automatically reused as necessary.

If you wish to maintain additional logs, I have written a script, BackupLog.bat, that copies and renames them. You will have to change the first few lines for the script to function in your environment:

Jerry is the user name context that NTBackup is run as.

D:\ZZZBackup is the folder where you want to store the copied backup logs.

DELOLD is freeware at tip 0274, and 31 is the number of days worth of log files that you want to keep.

bkpdata is set to the path of the backup log files, and doesn't need to be changed in most environments.

NOTE: The date and time formats in use at my location are mm/dd/yyyy and hh:mm.

I added a call backuplog to the end of my backup batch.

BackupLOg.bat contains:

@echo off
setlocal
set user=Jerry
set logs=D:\ZZZBackup
DELOLD %logs%\BckLog*.log 31
set bkpdata="C:\Documents and Settings\%user%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\"
for /f "Skip=4 Tokens=*" %%i in ('dir /od /tw /4 %bkpdata%backup*.log') do set line=%%i&call :parse
endlocal
goto end
:parse
if not "%line:~2,1%"=="/" goto end
FOR /F "Tokens=1-5 Delims=/: " %%j in ('@echo %line%') do call :parse1 %%j %%k %%l %%m %%n
goto end
:parse1
set name=BckLog_%3_%1_%2_%4_%5\[%line:~45,2%\].log
If exist %logs%\%name% goto end
copy %bkpdata%\backup%line:~45,2%.log %logs%\%name%
:end
The first time I ran BackupLog.bat, it produced the following files:
BckLog_2001_01_27_18_02\[06\].log
BckLog_2001_01_27_18_49\[07\].log
BckLog_2001_01_28_18_02\[08\].log
BckLog_2001_01_29_01_00\[09\].log
BckLog_2001_01_29_18_02\[10\].log
BckLog_2001_01_29_18_49\[01\].log
BckLog_2001_01_30_18_02\[02\].log
BckLog_2001_01_30_18_03\[03\].log
BckLog_2001_01_31_18_02\[04\].log
BckLog_2001_01_31_19_08\[05\].log


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish