Solved

robocopy errorlevel script not working

Posted on 2011-09-09
7
3,189 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
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
How to update Firmware and Bios in Dell Equalogic PS6000 Arrays and Hard Disks firmware update.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

813 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

13 Experts available now in Live!

Get 1:1 Help Now