Solved

I want to run a normal ntbackup (with verify) in a batch file and check if it completed successfully...

Posted on 2010-09-06
21
622 Views
Last Modified: 2012-05-10
I want to create a batch file that will run ntbackup (which I know how to do) and if it completes successfuly will delete certain outdated files, but if the backup does not complete successfuly I do not want to delete the files.

So I think I need a line in the file after the ntbackup command like:

If {error} then go skipit
  delete a
  delete b
  ...
:skipit

How do I test if the ntbackup job of my exchange data store (with verify on) completed  successfully (what expression goes in {error}?

Thank you experts.
0
Comment
Question by:Randy_R
  • 11
  • 6
  • 4
21 Comments
 

Author Comment

by:Randy_R
ID: 33611624
Actually I spoke too soon!  If I have .bks file with my backup job in it, how do I trigger that to run as a line in my .bat file on Windows 2000 SBS?
0
 
LVL 15

Expert Comment

by:Dave_AND
ID: 33611671
C:\WINDOWS\system32\ntbackup.exe backup "@C:\Backup.bks" /n "Media created 28/01/2010 at 12:59" /d "Set created 28/01/2010 at 12:59" /n "Media created 28/01/2010 at 12:59" /v:no /r:no /rs:no /hc:on /m normal /j "Backup" /l:s /p "4mm DDS" /um


Best way, create a backup job with windows backup, then go in to the scheduled job and copy the command line out (same as I have posted) just remember to put /UM at the end to use new media.

Hope this helps
0
 

Author Comment

by:Randy_R
ID: 33611792
Thank you.  And how do I check if the backup and verificaiton both completed successfullly?
0
 
LVL 15

Expert Comment

by:Dave_AND
ID: 33611818
Windows Backup has a logfile located in %user%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data

Not sure you you will be able to check it, but it should be easy as its just a txt file
0
 

Author Comment

by:Randy_R
ID: 33611890
Is it true that if there is a problem with the backup, then the .bkf file will not exist?  If so, maybe I can just test for its existence?

Also, I am trying to find the file that the task scheduler creates so I can cut and paste the code from it into my batch file, but I can't fine it.  Do you know where it is and how to open it?
0
 
LVL 15

Expert Comment

by:Dave_AND
ID: 33611906
Nope, it will create one and say what is wrong, or be blank.. sadly its not that easy :P

Make sure you have setup a backup job in NTBackup 1st, then Open control panel, scheduled tasks edit the backup task and the line you need will be there.
0
 

Author Comment

by:Randy_R
ID: 33611950
Ok, I see the code.

But I still need a way to check if the backup completed successfully.
0
 
LVL 15

Expert Comment

by:Dave_AND
ID: 33611993
Run a backup, and look at the log file, this will show you what a good backup should look like, that way at least you know what to look for. I cant help on parsing log files and reading them im afraid... sorry!
0
 

Author Comment

by:Randy_R
ID: 33612010
Maybe someone else can help me???
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 33616805
I run all my backups with scripts and then have the log files emailed to me. Here is a copy of one. If my backup does not complete I also get an email with an error log.

:FileBackup
Rem      Added for File backup 2007-09-25
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do Set dt=%%i%%l%%j%%k
for /f "Tokens=1-4" %%i in ('time /t') do Set tm=%%i%%j%%k
Set tm=%tm::=%
Set dtt1=%dt%%tm%
Rem      Set TapeName=%dt%
Set FileName=%dt%
Set >C:\Backup\Logs\Set1.Txt
Echo Backup into File started at %Time% >C:\Backup\Logs\FileStartTime.Txt
GoTo File

:File
ntbackup backup systemstate C:\ /n "%FileName%" /d "Drive-C to Drive-D for %dtt1%" /m normal /v:yes /r:no /rs:no /hc:on /j "Nightly Backup of Server1-C" /l:s /f "D:\Backup\%dt%.Bkf"
If ErrorLevel 1 GoTo File_ERR
Echo Backup File ended at %Time% >C:\Backup\Logs\FileEndTime.Txt
GoTo FileLog

:File_ERR
Echo There was an ERROR with Nightly Backup on %dtt1%>C:\Backup\Logs\NightlyERR-%dt%.Txt
C:\Utils\eMail\blat.exe "C:\Backup\Logs\NightlyERR-%dt%.Txt" -t sci@lionbusiness.com -s "Nightly Backup Error-%dtt1%" -uuencode -server mail.xyz.com -u abc@123.com -pw 345 -log "C:\Backup\Logs\Blat.Csv"
Net Send dlopez Error Nightly Backup DID NOT Complete Successfully!
GoTo FileLog

:FileLog
Set fld=C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\
Set fcmd=dir "%fld%*.log" /OD /A-D /B
for /F "tokens=* delims= " %%i in ('%fcmd%') do Set lastf=%fld%%%i
Copy "%lastf%" C:\Backup\Logs\%FileName%.log /y >C:\Backup\Logs\Log1.Txt
GoTo Logs

:Logs
Copy C:\Backup\Logs\%FileName%.Log \\server1\downloads\Nightly.Log /y

:EmailLogFiles
C:\Utils\eMail\blat.exe "C:\Backup\Logs\%FileName%.log" -t backup@southeastcompanies.com -s "Nightly Backup on %FileName%" -uuencode -server mail.abc.com -u abc@123.com -pw 345 -log "C:\Backup\Logs\Blat.Csv"
If ErrorLevel 1 GoTo eMail_Err
GoTo End

:eMail_Err
Net Send * Error SENDING eMail BUT Nightly Backup Completed Successfully!
GoTo Eject

:Eject
Rem      rsm.exe eject /PF"%TapeName% - 1" /astart >C:\Backup\Logs\Eject.Txt

:End
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Randy_R
ID: 33617149
So, "ErrorLevel 1" is dispositive of NTBackup not completing successfully?  If so, is this also true of Normal and Differential backups lionelmm?
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 33617442
This is not always true unfortunately. If backup does not start at all this errorlevel check works, like when a tape is missing or a drive is full. If back starts and then encounters and error my batch file does not always get the proper errorlevel but the log file I get by email, set to send me the summary, does. So in combination either bu errorlevel or by the email I always catch backup errors.
0
 

Author Comment

by:Randy_R
ID: 33617496
Is there a text phrase that reliably appears in the log file if everything, including verification, completes successfuly that I could check for in a batch file?
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 33617582
Backup completed on date at time

Example
(9/2/2010 at 11:18 PM.)
0
 

Author Comment

by:Randy_R
ID: 33619224
So if there is any error at all, that text won't be in the log file, correct?
0
 
LVL 24

Accepted Solution

by:
lionelmm earned 500 total points
ID: 33619600
If you are only backing up one drive or one folder then yes. There is a Backup successful for each backup job and a verify successful for each job as well, if you choose to verify.
0
 

Author Comment

by:Randy_R
ID: 33619612
Thank you very much.

One more question if you don't mind.  When sending mail from the batch file, why would I use blat over sendmail, or vice versa?
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 33619636
Its just one I know--if you prefer sendmail use it. Its just a question of habit--sendmail is probably better and safer I don't know.

Also I checked some of my logs that have errors and this may help you to look for as well
"The operation did not successfully complete" is what I get when backup did NOT complete successfully.

If you automate your logs with send mail mind sending me the script for that so I can try it--thanks?
0
 

Author Comment

by:Randy_R
ID: 33619706
No problem.  So, I'll leave the question open?
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 33619914
You can close it
 just email it to me if you remember. lionelmm@msn.com
0
 

Author Comment

by:Randy_R
ID: 33621341
Ok.  Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now