You are not logged in.
I use Robocopy to copy large ZIP files overnight over a WAN connection. Each file has its own directory, so even though there is wild-carding below, there's only one file actually available in each case.
-------------------------------------
IF %computername% == SERVER1 robocopy "D:\BACKUP-DR\zipped\%1" "\\SERVER2\d$\backup-dr\zipped" *.* /COPYALL /MOV /MT:10 /R:1 /LOG:"D:\BACKUP-DR\%computername%.%1.%2.log"
IF ERRORLEVEL 1 GOTO NORMAL
------------------------------------
Now here's where the problem came up the other night.
The destination side had a disk full problem (new server, monitoring system not yet set up!) so that the attempt to copy a few files failed. That part is fine. What dismayed me is the following:
1. The attempt failed and so did the retry. Yet, despite the fact that anything other than ERRORLEVEL 1 should kick up an error, the error-checking didn't catch it (and this checking has been verified for other types of errors, so I know it works).
2. Even though I use the /MOV option, I found out through past experience that ROBOCOPY doesn't always delete the files after they have been copied. Therefore, on a normal copy, I make sure everything is cleaned up with an RD statement. Well, because the batch file didn't detect the 112, it merrily deleted the file(s) that didn't get copied, thinking it had worked.
What's with ROBOCOPY returning a normal ERRORLEVEL when the copy failed along with the retry? Should I remove the /R:1 to force the 112 to get passed on?
Thanks,
Tom
(Log file below from the failed copy)
--------------------------------------------------------------
1 D:\BACKUP-DR\zipped\FILE1.DBF\
New File 321.6 m SERVER1.FILE1.DBF.2012-01-15.1-45-00.88.backup.zip
2012/01/15 02:47:11 ERROR 112 (0x00000070) Copying File D:\BACKUP-DR\zipped\FILE1.DBF\SERVER1.FILE1.DBF.2012-01-15.1-45-00.88.backup.zip
There is not enough space on the disk.
Waiting 30 seconds... Retrying... Retrying...
2012/01/15 02:48:04 ERROR 112 (0x00000070) Copying File D:\BACKUP-DR\zipped\FILE1.DBF\SERVER1.FILE1.DBF.2012-01-15.1-45-00.88.backup.zip
There is not enough space on the disk.
ERROR: RETRY LIMIT EXCEEDED.
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 1 0 0 0 1 743
Bytes : 321.63 m 0 0 0 321.63 m 339.847 g
Times : 0:31:10 0:00:40 0:00:00 0:29:47
Ended : Sun Jan 15 02:48:04 2012
Offline
This is a common misunderstanding with the IF command
IF ERRORLEVEL 1 will return TRUE when the errorlevel is 112
a more logical syntax is to use:
IF %ERRORLEVEL% EQU 0 Echo No error found
see http://ss64.com/nt/if.html for more examples
Offline
OK, so I'll change mine to read (because this is Robocopy)
------------------------------------------------
IF %ERRORLEVEL% EQU 1 Echo No error found
------------------------------------------------
Thanks!
-Tom-
Offline
Correction: IF %ERRORLEVEL% EQU 1 GOTO NORMAL
Offline
Offline
Correction: IF %ERRORLEVEL% EQU 1 GOTO NORMAL
Correction - it should read:
IF %ERRORLEVEL% EQU 1 GOTO NORMAL
IF %ERRORLEVEL% EQU 3 GOTO NORMAL
That's because a 1 and a 3 are both codes for good copies with no failures, no mismatches, etc. A 3 simply means that Robocopy is noticing files on the other side. I am using Robocopy only to move files, not to synchronize directories.
Offline
good point, I'll change that
Offline
Thanks again for your help. I don't recall but I may have scammed the code from that page. Thanks very much for your help. Any site that quotes Malcolm Muggeridge is already above-average. ;^)
Offline