We use NTBACKUP, run each evening, as a cheap solution to backups. We have created, with the help of EE member pbarrette (see question
http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20921686.html) a script which runs ntbackup & emails the status of the ntbackup job. However, the subject & description of the emails never changes, eventhough there could be problems. FYI, the original script backed up to tape (4mm), this script backs up to external USB hard disks. We also use a German OS, hence the funny German words!
I believe the :CHECKLOGFORERRORS part of the script is the problem. The script always gives a Subj of "%computername% Sicherung Erfolgreich abgeschlossen" and Desc of "Backup ran OK for %computername% at %USERDOMAIN% on" - eventhough, this may not be the case i.e. I have manually stopped the script, checked the log which has the string "Benutzer abgebrochen" within, but the script does not change the Subj or Desc variables.
Here is the script, any ideas?:
========= paste ===========
set blat=c:\downloads\blat\bla
t.exe
set Recipient=backup@domain.co
m
set Subj="%computername% Sicherung Erfolgreich abgeschlossen"
set Desc=Backup ran OK for %computername% at %USERDOMAIN% on
set Subj1="%computername% Sicherung mit Ausnahmen abgeschlossen"
set Subj2="%computername% Sicherung abgebrochen"
set Subj3="%computername% Sicherung mit Ausnahmen abgeschlossen"
set Subj4="%computername% Sicherung abgebrochen"
set Desc1=Problems with Exchange backup on %computername% at %USERDOMAIN% on
set Desc2=No external hard disk found on %computername% at %USERDOMAIN% on
set Desc3=Problems with the hard disk found on %computername% at %USERDOMAIN% on
set Desc4=Backup broken up by user on %computername% at %USERDOMAIN% on
set ntbackup=C:\WINNT\system32
\NTBACKUP.
EXE
set LOGDIR=%USERPROFILE%\Lokal
e Einstellungen\Anwendungsda
ten\Micros
oft\Window
s NT\NTBackup\data
set blatErrorFile="%temp%\%ran
dom%%rando
m%.txt"
set blatTEMPfile="%temp%\%rand
om%%random
%.txt"
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j%%k%%l
for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
set dtt=%dt%%tm%
for %%a in (V W X Y) do if exist %%a:\ set BackupJob=%%a.bks
if /i "%BackupJob%"=="V.bks" (
set jobDescription=Voll Sicherung Montag bis Freitag
set DriveLetter=V
)
if /i "%BackupJob%"=="W.bks" (
set jobDescription=Freitag Sicherung
set DriveLetter=W
)
if /i "%BackupJob%"=="X.bks" (
set jobDescription=Montag und Mittwoch Sicherung
set DriveLetter=X
)
if /i "%BackupJob%"=="Y.bks" (
set jobDescription=Dienstag und Donnerstag Sicherung
set DriveLetter=Y
)
:RUNBACKUP
%ntbackup% backup "@c:\scripts\backup\%Backu
pJob%" /n "%computername%-%dtt%" /d "%jobDescription%" /v:no /r:no /rs:no /m normal /j "%computername% voll Sicherung" /l:s /f "%DriveLetter%:\IHG-WTS & SV01.bkf"
:CHECKLOGFORERRORS
FOR /F %%F IN ('DIR /B /A-D /OD /TW "%LOGDIR%\Backup??.log"') DO (
SET LOGFILE=%%F
)
ECHO "%LOGDIR%\%LOGFILE%" | FINDSTR /C:"beschädigt oder unvollständig" > NUL
IF NOT ERRORLEVEL 1 (
set Subj=%Subj1%
set Desc=%Desc1%
GOTO BLAT
)
ECHO "%LOGDIR%\%LOGFILE%" | FINDSTR /C:"Medien nicht gefunden wurden" > NUL
IF NOT ERRORLEVEL 1 (
set Subj=%Subj2%
set Desc=%Desc2%
GOTO BLAT
)
ECHO "%LOGDIR%\%LOGFILE%" | FINDSTR /C:"Gerät meldete einen Fehler" > NUL
IF NOT ERRORLEVEL 1 (
set Subj=%Subj3%
set Desc=%Desc3%
GOTO BLAT
)
ECHO "%LOGDIR%\%LOGFILE%" | FINDSTR /C:"Benutzer abgebrochen" > NUL
IF NOT ERRORLEVEL 1 (
set Subj=%Subj4%
set Desc=%Desc4%
GOTO BLAT
)
:BLAT
echo %Desc% %dtt% > %blatTEMPfile%
%blat% %blatTEMPfile% -to %Recipient% -s %Subj% -attach "%LOGDIR%\%LOGFILE%"
del /q /f "%blatTEMPfile%"
goto :EOF
:EOF
exit
========= paste ===========