Solved

robocopy errorlevel script not working

Posted on 2011-09-09
7
3,258 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
VM backup deduplication is a method of reducing the amount of storage space needed to save VM backups. In most organizations, VMs contain many duplicate copies of data, such as VMs deployed from the same template, VMs with the same OS, or VMs that h…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

763 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