(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Error Levels == | == Error Levels == | ||
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | !Value !!Description | |
− | + | |- | |
− | + | | 0 || No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped. | |
− | + | |- | |
− | + | | 1 || All files were copied successfully. | |
− | + | |- | |
− | + | | 2 || There are some additional files in the destination directory that are not present in the source directory. No files were copied. | |
+ | |- | ||
+ | | 3 || Some files were copied. Additional files were present. No failure was encountered. | ||
+ | |- | ||
+ | | 4 || Some Mismatched files or directories were detected. | ||
+ | |- | ||
+ | | 5 || Some files were copied. Some files were mismatched. No failure was encountered. | ||
+ | |- | ||
+ | | 6 || 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. | ||
+ | |- | ||
+ | | 7 || Files were copied, a file mismatch was present, and additional files were present. | ||
+ | |- | ||
+ | | 8 || Several files did not copy. | ||
+ | |} | ||
+ | |||
Line 14: | Line 28: | ||
Robocopy is a great tool, but I came across an issue with it when using it within MS SQL Agent Job. | Robocopy is a great tool, but I came across an issue with it when using it within MS SQL Agent Job. | ||
− | The SQL Agent Job wants to know the exit status of the command that is run. This is quite common, and most command line applications return 0 (zero) upon successful completion of the command. This is not the case with Robocopy. Robocopy returns a bitmask value greater than 0 upon a successful copy. You can confirm this by running robocopy and then: | + | The SQL Agent Job wants to know the exit status of the command that is run. This is quite common, and most command line applications return 0 (zero) upon successful completion of the command. This is not the case with Robocopy. Robocopy returns a bitmask value greater than 0 upon a successful copy. Exit Codes are stored in %ERRORLEVEL%.You can confirm this by running robocopy and then: |
echo %ERRORLEVEL% | echo %ERRORLEVEL% | ||
− | + | ||
You can get around this by appending a logical and to the returned exit code like this: | You can get around this by appending a logical and to the returned exit code like this: | ||
Line 22: | Line 36: | ||
EXIT /B %ERRLVL% | EXIT /B %ERRLVL% | ||
This causes all exit codes below 8 to return a value of 0, and exit codes 8 or above (indicating an error) return the corresponding exit code. | This causes all exit codes below 8 to return a value of 0, and exit codes 8 or above (indicating an error) return the corresponding exit code. | ||
+ | |||
== Reference == | == Reference == | ||
https://support.microsoft.com/en-us/kb/954404 | https://support.microsoft.com/en-us/kb/954404 | ||
+ | |||
+ | http://ss64.com/nt/robocopy-exit.html | ||
http://weblogs.sqlteam.com/robv/archive/2010/02/17/61106.aspx | http://weblogs.sqlteam.com/robv/archive/2010/02/17/61106.aspx |
Latest revision as of 17:49, 23 May 2016
Error Levels
Value | Description |
---|---|
0 | No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped. |
1 | All files were copied successfully. |
2 | There are some additional files in the destination directory that are not present in the source directory. No files were copied. |
3 | Some files were copied. Additional files were present. No failure was encountered. |
4 | Some Mismatched files or directories were detected. |
5 | Some files were copied. Some files were mismatched. No failure was encountered. |
6 | 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. |
7 | Files were copied, a file mismatch was present, and additional files were present. |
8 | Several files did not copy. |
SQL Agent Job
Robocopy is a great tool, but I came across an issue with it when using it within MS SQL Agent Job.
The SQL Agent Job wants to know the exit status of the command that is run. This is quite common, and most command line applications return 0 (zero) upon successful completion of the command. This is not the case with Robocopy. Robocopy returns a bitmask value greater than 0 upon a successful copy. Exit Codes are stored in %ERRORLEVEL%.You can confirm this by running robocopy and then:
echo %ERRORLEVEL%
You can get around this by appending a logical and to the returned exit code like this:
SET /A ERRLVL="%ERRORLEVEL & 24" EXIT /B %ERRLVL%
This causes all exit codes below 8 to return a value of 0, and exit codes 8 or above (indicating an error) return the corresponding exit code.
Reference
https://support.microsoft.com/en-us/kb/954404
http://ss64.com/nt/robocopy-exit.html
http://weblogs.sqlteam.com/robv/archive/2010/02/17/61106.aspx