Solved

robocopy errorlevel script not working

Posted on 2011-09-09
7
3,342 Views
Last Modified: 2012-05-12

I received an error last night but it didn't notify me.
Below is the script that I run and tested.

prior: To test I changed errorlevel 0 to notify then reran the job and it generated an email as expected so the email portion of the script I believe is working.

error: the log shows error 21 (0x0000000015).

Is that errorlevel 21 or 15?
Did it not work right or do I need to create an errorlevel 21?
I'm not much of a programmer so any insight would be greatly appreciated.
thanks

LOG:
2011/08/30 20:02:43 ERROR 21 (0x00000015) Accessing Source Directory D:\data\
The device is not ready.
ERROR: RETRY LIMIT EXCEEDED.
2011/08/30 20:02:44 ERROR 21 (0x00000015) Accessing Source Directory D:\data\
The device is not ready.

here is my script:
robocopy "D:\data" "\nas-2\BranchDataBackUp\XXX\data" /S /PURGE /V /XO /NP /LOG:"\\nas-2\BranchDataBackUp\XXXdata.txt" /B /R:10 /W:15
if errorlevel 16 echo ***FATAL ERROR*** & goto notify
if errorlevel 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto notify
if errorlevel 14 echo FAIL + MISMATCHES + XTRA & goto notify
if errorlevel 13 echo OKCOPY + FAIL + MISMATCHES & goto notify
if errorlevel 12 echo FAIL + MISMATCHES & goto notify
if errorlevel 11 echo OKCOPY + FAIL + XTRA & goto notify
if errorlevel 10 echo FAIL + XTRA & goto notify
if errorlevel 9 echo OKCOPY + FAIL & goto notify
if errorlevel 8 echo FAIL & goto notify
if errorlevel 7 echo OKCOPY + MISMATCHES + XTRA & goto end
if errorlevel 6 echo MISMATCHES + XTRA & goto end
if errorlevel 5 echo OKCOPY + MISMATCHES & goto end
if errorlevel 4 echo MISMATCHES & goto end
if errorlevel 3 echo OKCOPY + XTRA & goto end
if errorlevel 2 echo XTRA & goto end
if errorlevel 1 echo OKCOPY & goto end
if errorlevel 0 echo No Change & goto end
:Notify
C:\WINDOWS\system32\blat -install exchange.<name>.com BackUp
C:\WINDOWS\system32\blat \\Nt-nas-2\BranchDataBackUp\XXXdata.txt -subject "XXX data BackUpConcerns" -to sysmon@<domain>.com
Goto End
:End
0
Comment
Question by:GoHuskers
[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
  • 4
  • 3
7 Comments
 
LVL 8

Accepted Solution

by:
pwust earned 500 total points
ID: 36513462
The if statement only takes the first command. The rest will be executed in every case.

In order to execute a group of commands, put them in parentheses:
...
if errorlevel 16 (echo ***FATAL ERROR*** & goto notify)
if errorlevel 15 (echo OKCOPY + FAIL + MISMATCHES + XTRA & goto notify)
if errorlevel 14 (echo FAIL + MISMATCHES + XTRA & goto notify)
if errorlevel 13 (echo OKCOPY + FAIL + MISMATCHES & goto notify)
if errorlevel 12 (echo FAIL + MISMATCHES & goto notify)
if errorlevel 11 (echo OKCOPY + FAIL + XTRA & goto notify)
if errorlevel 10 (echo FAIL + XTRA & goto notify)
if errorlevel 9 (echo OKCOPY + FAIL & goto notify)
if errorlevel 8 (echo FAIL & goto notify)
if errorlevel 7 (echo OKCOPY + MISMATCHES + XTRA & goto end)
if errorlevel 6 (echo MISMATCHES + XTRA & goto end)
if errorlevel 5 (echo OKCOPY + MISMATCHES & goto end)
if errorlevel 4 (echo MISMATCHES & goto end)
if errorlevel 3 (echo OKCOPY + XTRA & goto end)
if errorlevel 2 (echo XTRA & goto end)
if errorlevel 1 (echo OKCOPY & goto end)
if errorlevel 0 (echo No Change & goto end)
...

Open in new window

0
 

Author Comment

by:GoHuskers
ID: 36523110
I have added the parentheses but it echos  no change even though there is an error still.
I do erase the log file so it has to create a new one each time.
it seems to go to errorlevel 0 regardless
any ideas?
I have attached the script and the log

logfile:
-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP026
-------------------------------------------------------------------------------

  Started : Mon Sep 12 09:19:32 2011

2011/09/12 09:19:32 ERROR 21 (0x00000015) Getting File System Type of Source d:\data\
The device is not ready.


   Source - d:\data\
     Dest : \\nas\BranchDataBackUp\XXX\data\
    Files : *.*
   
  Options : *.* /V /S /COPY:DAT /PURGE /B /NP /XO /R:1 /W:15
------------------------------------------------------------------------------

2011/09/12 09:19:32 ERROR 21 (0x00000015) Accessing Source Directory d:\data\
The device is not ready.

Waiting 15 seconds... Retrying...
2011/09/12 09:19:48 ERROR 21 (0x00000015) Accessing Source Directory d:\data\
The device is not ready.


ERROR: RETRY LIMIT EXCEEDED.

2011/09/12 09:19:48 ERROR 21 (0x00000015) Accessing Source Directory d:\data\
The device is not ready.

script:
robocopy "d:\data" "\\nas\BranchDataBackUp\xxx\data" /S /PURGE /V /XO /NP /LOG:"\\nas\BranchDataBackUp\xxxdata.txt" /B /R:1 /W:15
if errorlevel 16 (echo ***FATAL ERROR*** & goto notify)
if errorlevel 15 (echo OKCOPY + FAIL + MISMATCHES + XTRA & goto notify)
if errorlevel 14 (echo FAIL + MISMATCHES + XTRA & goto notify)
if errorlevel 13 (echo OKCOPY + FAIL + MISMATCHES & goto notify)
if errorlevel 12 (echo FAIL + MISMATCHES & goto notify)
if errorlevel 11 (echo OKCOPY + FAIL + XTRA & goto notify)
if errorlevel 10 (echo FAIL + XTRA & goto notify)
if errorlevel 9 (echo OKCOPY + FAIL & goto notify)
if errorlevel 8 (echo FAIL & goto notify)
if errorlevel 7 (echo OKCOPY + MISMATCHES + XTRA & goto end)
if errorlevel 6 (echo MISMATCHES + XTRA & goto end)
if errorlevel 5 (echo OKCOPY + MISMATCHES & goto end)
if errorlevel 4 (echo MISMATCHES & goto end)
if errorlevel 3 (echo OKCOPY + XTRA & goto end)
if errorlevel 2 (echo XTRA & goto end)
if errorlevel 1 (echo OKCOPY & goto good)
if errorlevel 0 (echo No Change & goto good)

:Notify
C:\WINDOWS\system32\blat -install ntexchange.domain.com BackUp
C:\WINDOWS\system32\blat \\nas\BranchDataBackUp\HUDdata.txt -subject "xxx data BackUpConcerns" -to sysmon@domain.com
Goto End

:GOOD
C:\WINDOWS\system32\blat -install ntexchange.domain.com BackUp
C:\WINDOWS\system32\blat \\nas\BranchDataBackUp\xxxdata.txt -subject "xxx data It's all good!!!" -to sysmon@domain.com
GOTO END

:End
0
 
LVL 8

Expert Comment

by:pwust
ID: 36525548
Does it change its output if you put in the complete path and filename of your robocopy.exe?

you also can add a line
echo exit code is %errorlevel%.

Open in new window

just between the "robocopy" line and the "if" series of lines, just to see what you have just before starting the error handling.

0
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 

Author Comment

by:GoHuskers
ID: 36525641
just to clarify. Is this what you meant?
C:\WINDOWS\system32\robocopy.exe "c:\Profiles" "\\nas\BranchDataBackUp\..................
echo exit code is %errorlevel%
if errorlevel16 (echo ***FATAL ERROR*** & goto notify)
....................
0
 
LVL 8

Expert Comment

by:pwust
ID: 36525897
yes, confirmed
0
 

Author Comment

by:GoHuskers
ID: 36529121
well it keeps returning an exit code of 0 eventhough it gives an error code in the log.
I purposely change the source drive letter to create an error.
Is error 21 not a valid exit code to be using how I am trying?
or is there a bug in robocopy?
see below for log

error log:
2011/09/13 07:32:37 ERROR 21 (0x00000015) Accessing Source Directory d:\Profiles\
The device is not ready.

Waiting 15 seconds... Retrying...
2011/09/13 07:32:53 ERROR 21 (0x00000015) Accessing Source Directory d:\Profiles\
The device is not ready.


ERROR: RETRY LIMIT EXCEEDED.

2011/09/13 07:32:53 ERROR 21 (0x00000015) Accessing Source Directory d:\Profiles\
The device is not ready.

0
 

Author Comment

by:GoHuskers
ID: 36529659
i figured out the exit code issue.
I had to revert back to an earlier version of Robocopy  XP010
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to update Firmware and Bios in Dell Equalogic PS6000 Arrays and Hard Disks firmware update.
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

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