Официальная возможность получить лицензионный софт бесплатно.
Giveaway of the Day
Это не реклама!

Щелкните для получения прогноза по Биробиджану


понедельник, 14 марта 2016 г.

RoboCopy: коды завершения

Есть у микрософта бледное подобие rsync-a, называется robocopy - robust file copy.
Ну, особо придраться не к чему - бледное подобие оно и есть бледное подобие. Но поскольку микрософт уверен, что все серверы в мире подключены к интернету и не поставляет оффлайновую справку, то лучше подстраховаться и кое-что из документации вынести в блог.

Коды завершения работы:
(кто-то вроде меня так же ведет блог, записывая туда свои "открытия", чтобы не искать их повторно)
Использована информация из базы знаний микрософта. У микрософта информация по комбинациям кодов немного полнее.
===

ROBOCOPY Exit Codes

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  
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
===

Комментариев нет:

Отправить комментарий

Пожалуйста, воздержитесь от грубостей и персональных нападок.
Я не против матерщины, но она должна быть уместной и использоваться для выражения эмоций, а не в качестве основного средства выражения мыслей.