robocopy exit codes ... is robocopy just buggy or am I missing something?

4

We're using robocopy (file version 5.1.10.1027) to mirror directory trees. robocopy is called by a python script rather than manually. We're relying on robocopy's exit codes to determine whether the operation was successful or not. If successful, our script proceeds to do a lot of other fancy stuff. Else it aborts immmediately.

Allegedly, robocopy's exit code is a bit field with the following flags (https://ss64.com/nt/robocopy-exit.html):

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.

Going by this information, any exit code greater than 7 can be assumed to mean that at least one error occurred, so this is the criterion our script uses to determine whether robocopy succeeded.

Now we've run into an issue where robocopy fails to delete a file in the destination that is no longer present in the source, due to an access-denied problem:

  *EXTRA File            661    AdminTable_version.h
  2017/06/13 02:38:08 ERROR 5 (0x00000005) Deleting Extra File E:\fw_cu\build\output\AdminTable_version.h

Access is denied.

but then returns with an exit code of 3 anyway. In other words, flags 0x01 and 0x02 are set, meaning:

One or more files were copied successfully (that is, new files have arrived).

and

Some Extra files or directories were detected. No files were copied
Examine the output log for details.

We're using the following command line:

robocopy.exe M:\fw_cu E:\fw_cu /MIR /FFT /W:5 /NP

Now, unless I'm missing something, these exit code flags either do not convey enough information to reliably tell whether the operation was 100% successful, or robocopy is simply not using them consistently. I feel like failure to delete at least one file during a mirroring operation would warrant either the 0x08 or the 0x10 flag.

windows
robocopy
asked on Stack Overflow Jun 13, 2017 by antred

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0