robocopy退出代码... robocopy只是马车或我错过了什么?

时间:2017-06-13 15:26:16

标签: windows robocopy

我们正在使用robocopy(文件版本5.1.10.1027)来镜像目录树。 robocopy由python脚本而不是手动调用。我们依靠robocopy的退出代码来确定操作是否成功。如果成功,我们的脚本会继续做很多其他花哨的事情。否则它会立即中止。

据称,robocopy的退出代码是一个带有以下标志(https://ss64.com/nt/robocopy-exit.html)的位字段:

十六进制十进制含义,如果设置

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.

根据这些信息,可以假设任何大于7的退出代码表示至少发生了一个错误,因此这是我们的脚本用来确定robocopy是否成功的标准。

现在我们遇到了一个问题,即robocopy无法删除源中不再存在的文件,因为访问被拒绝了问题:

  *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

访问被拒绝。

然后以退出代码3返回。换句话说,标志0x01和0x02被设置,意思是:

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

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

我们使用以下命令行:

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

现在,除非我遗漏了某些东西,否则这些退出代码标记要么没有传达足够的信息来可靠地判断操作是否100%成功,或者robocopy根本就没有使用它们。我觉得在镜像操作期间无法删除至少一个文件会保证0x08或0x10标志。

0 个答案:

没有答案