The return code from Robocopy is a bitmap, defined as follows:
Hex Decimal Meaning if set 0×00 0 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized. 0×01 1 One or more files were copied successfully (that is, new files have arrived). 0×02 2 Some Extra files or directories were detected. No files were copied Examine the output log for details. 0×04 4 Some Mismatched files or directories were detected. Examine the output log. Housekeeping might be required. 0×08 8 Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. 0×10 16 Serious error. Robocopy did not copy any files. Either a usage error or an error due to insufficient access privileges on the source or destination directories.
These can be combined, giving a few extra exit codes:
0×03 3 (2+1) Some files were copied. Additional files were present. No failure was encountered. 0×05 5 (4+1) Some files were copied. Some files were mismatched. No failure was encountered. 0×06 6 (4+2) Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory 0×07 7 (4+1+2) Files were copied, a file mismatch was present, and additional files were present.
Any value greater than 7 indicates that there was at least one failure during the copy operation.
You can use this in a batch file to report anomalies, as follows:
if %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto end if %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto end if %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto end if %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto end if %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto end if %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto end if %ERRORLEVEL% EQU 8 echo FAIL & goto end if %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto end if %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto end if %ERRORLEVEL% EQU 4 echo MISMATCHES & goto end if %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA & goto end if %ERRORLEVEL% EQU 2 echo XTRA & goto end if %ERRORLEVEL% EQU 1 echo OKCOPY & goto end if %ERRORLEVEL% EQU 0 echo No Change & goto end :end
Error 0x800700DF: The file size exceeds the limit allowed and cannot be saved.
This error may appear when copying from a WEBdav drive, WEBdav ignores/limits the /MAX setting of robocopy.
This can be set in the Windows Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters
The key FileSizeLimitInBytes defines the WEBdav max-size in decimal bytes.
To set a limit of 4 GiB change this value to 4294967295
The default is 50000000 bytes. (50 MB)WEBdav also has a default limit of 1800 seconds (30 minutes) download time, this can be extended see Q2668751
Example:
Copy files from one server to another
ROBOCOPY \\Server1\reports \\Server2\backup *.*
IF %ERRORLEVEL% LSS 8 goto finish
Echo Something failed & goto :eof
:finish
Echo All done, no fatal errors.
Bugs
Version XP026 returns a success errorlevel even when it fails.
“Few men of action have been able to make a graceful exit at the appropriate time” ~ Malcolm Muggeridge
Related:
Robocopy -
Robust File and Folder Copy.
Q954404 - Robocopy Return codes in Windows 2008 R2.
Copy Open files - with VShadow.exe (Shadow copies).
Equivalent bash command:
rsync - Remote file copy (Synchronize file trees).