Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 25

Expert Comment

by:Lionel MM
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
 

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 25

Expert Comment

by:Lionel MM
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 25

Expert Comment

by:Lionel MM
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 25

Accepted Solution

by:
Lionel MM earned 2000 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 25

Expert Comment

by:Lionel MM
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 25

Expert Comment

by:Lionel MM
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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
This video discusses moving either the default database or any database to a new volume.

670 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