Robocopy ошибка 0 0x00000000

Есть у микрософта бледное подобие 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 Server1reports Server2backup *.*
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

===

I’m trying to do a QNAP (linux NAS) samba shares that have about 8TB of data on it to a Windows based file server so I can properly make backups using VEEAM.

Anyways, I’ve been able to seed the 8TB fine mostly. A few hundred files of about 18 million don’t make it over.

Here is an example of my robocopy script:

robocopy 2.168.5.80share1 z:sharesshare1 /mir /copyall /w:1 /r:2 /mir /ZB /log:z:logstf.txt /NFL /NDL /NP

Here is an example of the errors.

2018/04/04 12:06:22 ERROR 0 (0x00000000)  2.168.5.80share1somefolder
The operation completed successfully.

I check the destination and it’s not there. My research on the issue indicates that it may be a permissions issue, and I verified the security permissions are the same as other folders that successfully copied.

I’ve been working at it most of hte day and my researching isn’t coming up with anything.

Does anyone have any suggestions on how to fix this, or another copy tool that can copy over all security permissions and such?

Thanks all!

  • Remove From My Forums
  • Question

  • Hi All,

    I am receiving an error while copying a folder from one server to other server 

    the cmd which i am using is 

    robocopy newftC$Newfolder newft2C$Jyothsna /COPYALL

    the below error i am getting

    C:UsersDemouser>robocopy newftC$Newfolder newft2C$Jyothsna /COPYALL

    ——————————————————————————-
       ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
    ——————————————————————————-

      Started : Thu Oct 04 07:53:42 2018

    2018/10/04 07:53:42 ERROR 67 (0x00000043) Getting File System Type of Source newftC$Newfolder
    The network name cannot be found.

    2018/10/04 07:54:04 ERROR 53 (0x00000035) Getting File System Type of Destination newft2C$Jyothsna
    The network path was not found.

       Source — newftC$Newfolder
         Dest — newft2C$Jyothsna

        Files : *.*

      Options : *.* /COPYALL /R:1000000 /W:30

    ——————————————————————————

    NOTE: NTFS Security may not be copied — Source may not be NTFS.

    NOTE: NTFS Security may not be copied — Destination may not be NTFS.

    2018/10/04 07:54:04 ERROR 67 (0x00000043) Accessing Source Directory newftC$Newfolder
    The network name cannot be found.

Answers

  • Hi,

    You have forgotten the backslashes, try this:

    robocopy newftC$Newfolder newft2C$Jyothsna /COPYALL

    Best regards,
    Leon


    Blog:
    https://thesystemcenterblog.com
    LinkedIn:

    • Marked as answer by

      Thursday, October 4, 2018 11:26 AM

  • Works fine for me, make sure you’re able to resolve your hostname (or use FQDN) or then try with IP address.


    Blog:
    https://thesystemcenterblog.com
    LinkedIn:

    • Marked as answer by
      Jyothsnamadanu
      Thursday, October 4, 2018 11:26 AM
  • Make sure you have administrator permissions to both source and destination computers, as you are using $ shares (which are hidden shares only viewable for administrators).

    Edit: Also make sure that NetBIOS over TCP/IP is still enabled on the relevant network adapters. 


    Blog:

    https://thesystemcenterblog.com LinkedIn:

    • Edited by
      Leon Laude
      Thursday, October 4, 2018 11:02 AM
      Added one line
    • Marked as answer by
      Jyothsnamadanu
      Thursday, October 4, 2018 11:26 AM
  • Remove From My Forums
  • Question

  • Hello All,

    Am pretty new with robocopy, am getting below error when I’m trying to copy folders from one server to another server using robocopy below are the error I’m receiving in the log file.

    Error 1 — .1.txt:274352:2017/10/30 07:59:44 ERROR 1463 (0x000005B7) Copying File <IP>d$-=BNO-GRPSBNO — CommonITRock masterExceptionsAdobeMuse7.0-mulInstall Adobe Muse.appContentsResourcesAdobe MuseContentsResourcesMETA-INFAIRextensionscom.adobe.linguistics.extensions.HunspellNativeExtensionMETA-INFANEMacOS-x86HunspellNativeExtension.frameworkHunspellNativeExtension

    Error 2 — .1.txt:274447:2017/10/30 07:59:45 ERROR 32 (0x00000020) Copying File <IP>d$-=BNO-GRPSPKS-DATANHSD Documents  Documents du DGLHNHSMBC   CLMHCHSMBC Plaque Images  Images des plaques de la CLMHCNational Historic
    Persons  Personnages historiques nationalesCOSBY_~1.JPG

    OS in both servers in Win2k8

    Thanks in advance,

    Samojit

    • Edited by

      Tuesday, October 31, 2017 5:20 PM

  • Remove From My Forums
  • Question

  • Hello All,

    Am pretty new with robocopy, am getting below error when I’m trying to copy folders from one server to another server using robocopy below are the error I’m receiving in the log file.

    Error 1 — .1.txt:274352:2017/10/30 07:59:44 ERROR 1463 (0x000005B7) Copying File <IP>d$-=BNO-GRPSBNO — CommonITRock masterExceptionsAdobeMuse7.0-mulInstall Adobe Muse.appContentsResourcesAdobe MuseContentsResourcesMETA-INFAIRextensionscom.adobe.linguistics.extensions.HunspellNativeExtensionMETA-INFANEMacOS-x86HunspellNativeExtension.frameworkHunspellNativeExtension

    Error 2 — .1.txt:274447:2017/10/30 07:59:45 ERROR 32 (0x00000020) Copying File <IP>d$-=BNO-GRPSPKS-DATANHSD Documents  Documents du DGLHNHSMBC   CLMHCHSMBC Plaque Images  Images des plaques de la CLMHCNational Historic
    Persons  Personnages historiques nationalesCOSBY_~1.JPG

    OS in both servers in Win2k8

    Thanks in advance,

    Samojit

    • Edited by

      Tuesday, October 31, 2017 5:20 PM

Is it possible to ask ROBOCOPY to exit with an exit code that indicates success or failure?

I am using ROBOCOPY as part of my TeamCity build configurations, and having to add a step to just silence the exit code from ROBOCOPY seems silly to me.

Basically, I have added this:

EXIT /B 0

to the script that is being run.

However, this of course masks any real problems that ROBOCOPY would return.

Basically, I would like to have exit codes of 0 for SUCCESS and non-zero for FAILURE instead of the bit-mask that ROBOCOPY returns now.

Or, if I can’t have that, is there a simple sequence of batch commands that would translate the bit-mask of ROBOCOPY to a similar value?

asked May 7, 2011 at 13:03

Lasse V. Karlsen's user avatar

Lasse V. KarlsenLasse V. Karlsen

3,60410 gold badges40 silver badges58 bronze badges

1

As per here, Robocopy has the following exit code bits that make up the exit code:

0×10 Serious error. Robocopy did not copy any files. This is either a usage error or an error due to insufficient access privileges on the source or destination directories.

0×08 Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further.

0×04 Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary.

0×02 Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed.

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

0×00 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.

Just add if/else statements that EXIT /B 0 when the return value is 1 or maybe 0, and EXIT /B 1 otherwise. Even if files might have been copied, there’s something wrong that would need manual intervention.

Community's user avatar

answered May 7, 2011 at 13:34

Daniel Beck's user avatar

Daniel BeckDaniel Beck

108k14 gold badges285 silver badges330 bronze badges

3

TechNet suggests this one-liner to convert the exit code into a more traditional exit code:

(robocopy c:dirA c:dirB *.*) ^& IF %ERRORLEVEL% LEQ 1 exit 0

Or this to ignore the exit code completely (i.e. don’t care if it failed or succeeded):

(robocopy c:dirA c:dirB *.*) ^& exit 0

However, both commands above will terminate a script after the robocopy has executed. This is an issue especially for CI builds. If you want to use robocopy in this scenario, you need to set the error code manually for irrelevant exit codes. Below, all error codes below 8 will be rewritten to no error at all, and the script will be continued if possible.

(robocopy c:dirA c:dirB *.*) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0

7

Running it from Jenkins needs both ( ) and /B. If you want to ignore the error level 1,2,3,4:

(robocopy XXX YYY) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0

answered Jun 18, 2012 at 5:26

Filippo Vitale's user avatar

4

From this page you can add a section to your batch file that uses the list of error codes to output the errors and run different sections of code:

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
REM END OF BATCH FILE

x29a's user avatar

x29a

7936 silver badges10 bronze badges

answered May 7, 2011 at 13:35

Mokubai's user avatar

MokubaiMokubai

86.7k25 gold badges198 silver badges222 bronze badges

Some posters above have missed the subtlety of the bit mask. In particular paradroid has missed that errorlevel 3 indicates a completely successful copy.

Note that bit 0x01 if set indicates that some files have been copied even if there were other failures. So any odd numbered errorlevels always indicate that at least some files have been copied.
Note also that bit 0x02 simply indicates that there are files at the destination that are not present at the source. This will happen if the /E switch is used and files have been deleted from the source since a previous copy was taken. It should not happen if the /MIR switch is used because that should delete files at the destination to mirror the source (but I haven’t tested this).

So both errorlevel 1 AND 3 indicate successful copying of files with no errors.
Also errorlevels 0 AND 2 indicate that the destination is up to date and no files were copied.

For what its worth I came up with the following for my simple backup:

if errorlevel 16 echo Backup failed - see reason above & goto done

if errorlevel 8 echo All is not well - backup incomplete & goto done

if errorlevel 4 echo All is not well - some files were mismatched & goto done

if errorlevel 3 echo Backup completed successfully & goto done

if errorlevel 2 echo Backup already up to date - no files copied & goto done

if errorlevel 1 echo Backup completed successfully & goto done

if errorlevel 0 echo Backup already up to date - no files copied & goto done

I chose not to bother about the ‘extra’ files.

I have no idea what the ‘mismatched’ error is because it hasn’t happened yet but I allowed for it just in case.

Richard's user avatar

Richard

5,6449 gold badges41 silver badges66 bronze badges

answered Apr 3, 2014 at 23:56

GuestJohn's user avatar

GuestJohnGuestJohn

911 silver badge1 bronze badge

I use this:

robocopy .....
call :REPORT_ERRORLEVEL
goto :EOF

:REPORT_ERRORLEVEL
echo.
if ERRORLEVEL 16 echo ***FATAL ERROR*** & goto :EOF
if ERRORLEVEL 8 echo **FAILED COPIES** & goto :EOF
if ERRORLEVEL 4 echo *MISMATCHES* & goto :EOF
if ERRORLEVEL 2 echo EXTRA FILES & goto :EOF
if ERRORLEVEL 1 echo Copy successful & goto :EOF
if ERRORLEVEL 0 echo –no change– & goto :EOF

answered May 7, 2011 at 14:54

paradroid's user avatar

paradroidparadroid

22.5k10 gold badges72 silver badges113 bronze badges

I agree with Guest John — you really only want to indicate an error if the result is actually 8 or higher.

so to map a robocopy result to a 0 (success) or 1 (fail) result, suitable for use in a SQL Agent job, I am using this:

  IF %ERRORLEVEL% LSS 8 EXIT /B 0
  EXIT /B 1

answered Oct 24, 2014 at 3:36

ElectricLlama's user avatar

For TeamCity I’m using this and it’s working quite well. Thanks to input from MikeWyatt, DaoCacao, and Yan Sklyarenko. I just needed to see a full working example to help visualize the answer.

(robocopy  .ArtifactsFitnesse %FitDestinationFolder% /MIR)
IF %%ERRORLEVEL%% LEQ 3 set errorlevel=0
IF %%ERRORLEVEL%% NEQ 0 EXIT /b %%ERRORLEVEL%%
EXIT 0

answered Feb 5, 2015 at 1:01

Paul Oliver's user avatar

Paul OliverPaul Oliver

2682 silver badges8 bronze badges

1

add cmd /c before it for gitlab ci.

cmd /c (robocopy c:dirA c:dirB *.*) ^& IF %ERRORLEVEL% LEQ 1 exit 0

otherwise EXIT 0 closes the CI pipeline at that point.

answered Nov 8, 2017 at 22:20

Scobber's user avatar

1

An example here on how to copy finished files from Visual Studio 2010+ to another folder as Visual Studio expects a 0 not 1 on a good copy.

cmd /c (robocopy $(TargetDir) X:$(TargetName) $(TargetFileName) $(TargetFileName).config *.dll *.json *.xml /xx) ^& IF %ERRORLEVEL% LEQ 1 exit 0 

answered Jun 21, 2017 at 23:49

Glenn Perkins's user avatar

Here’s how I would do it:

robocopy [...] & if not errorlevel 4 ver > nul

Assuming that extra files are OK, but mismatched files are not, then exit codes 0, 1, 2 and 3 indicate success and all other indicate failure.

(Mismatched meaning we are trying to copy a file, but we can’t because there’s already a directory with the same name there.)

In batch files/cmd, exit codes set the ERRORLEVEL. To reset the ERRORLEVEL to 0 (success) we can use the fact that ver returns 0 (and discard the output). If it’s 4 or greater, we can just leave the ERRORLEVEL unchanged.

Example:

robocopy C:tempfoo C:tempbar test.txt & if not errorlevel 4 ver > nul && echo Copy OK

answered Jun 16, 2021 at 9:49

johv's user avatar

johvjohv

1511 gold badge1 silver badge3 bronze badges


Можно ли попросить ROBOCOPY выйти с кодом выхода, который указывает на успех или неудачу?

Я использую ROBOCOPY как часть моих конфигураций сборки TeamCity, и необходимость добавлять шаг, чтобы просто заставить замолчать код выхода из ROBOCOPY, кажется мне глупой.

В основном я добавил это:

EXIT /B 0

к сценарию, который выполняется.

Тем не менее, это, конечно, маскирует любые реальные проблемы, которые ROBOCOPY вернет.

По сути, я хотел бы иметь коды выхода 0 для УСПЕХА и ненулевые для НЕИСПРАВНОСТИ вместо битовой маски, которую РОБОКОПИЯ возвращает сейчас.

Или, если у меня этого нет, есть ли простая последовательность командных команд, которая бы переводила битовую маску ROBOCOPY в аналогичное значение?


Ответы:


Как здесь , Robocopy имеет следующие биты кода выхода, которые составляют код выхода:

0 × 10 Серьезная ошибка. Robocopy не копировал никаких файлов. Это либо ошибка использования, либо ошибка из-за недостаточных прав доступа к исходным или целевым каталогам.

0 × 08 Не удалось скопировать некоторые файлы или каталоги (возникли ошибки при копировании и превышен предел повторных попыток). Проверьте эти ошибки дальше.

0 × 04 Обнаружены некоторые несоответствующие файлы или каталоги. Изучите выходной журнал. Домашнее хозяйство, вероятно, необходимо.

0 × 02 Обнаружены некоторые дополнительные файлы или каталоги. Изучите выходной журнал. Некоторая уборка может быть необходима.

0 × 01 Один или несколько файлов были успешно скопированы (то есть поступили новые файлы).

0 × 00 Не было ошибок, и копирование не было выполнено. Деревья каталогов источника и назначения полностью синхронизированы.

Просто добавьте операторы if / else, EXIT /B 0когда возвращаемое значение равно 1 или, возможно, 0, и EXIT /B 1иначе. Даже если файлы могли быть скопированы, есть что-то не так, что потребует ручного вмешательства.


TechNet предлагает этот однострочный конвертировать код выхода в более традиционный код выхода:

(robocopy c:dirA c:dirB *.*) ^& IF %ERRORLEVEL% LEQ 1 exit 0

Или это, чтобы полностью игнорировать код выхода (т.е. не волнует, провалился ли он или преуспел):

(robocopy c:dirA c:dirB *.*) ^& exit 0

Однако обе приведенные выше команды прекратят выполнение сценария после выполнения робокопии. Это проблема особенно для сборок CI. Если вы хотите использовать robocopy в этом сценарии, вам нужно вручную установить код ошибки для нерелевантных кодов выхода. Ниже все коды ошибок ниже 8 будут переписаны без ошибок, и сценарий будет продолжен, если это возможно.

(robocopy c:dirA c:dirB *.*) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0






Для запуска от Дженкинса нужны и то ( )и другое /B. Если вы хотите игнорировать уровень ошибки 1,2,3,4:

(robocopy XXX YYY) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0


На этой странице вы можете добавить в свой пакетный файл раздел, который использует список кодов ошибок для вывода ошибок и запуска различных разделов кода:

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
REM END OF BATCH FILE

Я использую это:

robocopy .....
call :REPORT_ERRORLEVEL
goto :EOF

:REPORT_ERRORLEVEL
echo.
if ERRORLEVEL 16 echo ***FATAL ERROR*** & goto :EOF
if ERRORLEVEL 8 echo **FAILED COPIES** & goto :EOF
if ERRORLEVEL 4 echo *MISMATCHES* & goto :EOF
if ERRORLEVEL 2 echo EXTRA FILES & goto :EOF
if ERRORLEVEL 1 echo Copy successful & goto :EOF
if ERRORLEVEL 0 echo –no change– & goto :EOF

Некоторые постеры выше пропустили тонкость битовой маски. В частности, Paradroid пропустил, что уровень ошибки 3 указывает на полностью успешную копию.

Обратите внимание, что бит 0x01, если установлен, указывает, что некоторые файлы были скопированы, даже если были другие сбои. Поэтому любые нечетные уровни ошибок всегда указывают, что по крайней мере некоторые файлы были скопированы. Также обратите внимание, что бит 0x02 просто указывает, что в месте назначения есть файлы, которых нет в источнике. Это произойдет, если используется ключ / E и файлы были удалены из источника с момента создания предыдущей копии. Это не должно происходить, если используется ключ / MIR, потому что это должно удалить файлы в месте назначения, чтобы отразить источник (но я не проверял это).

Таким образом, оба уровня ошибок 1 и 3 указывают на успешное копирование файлов без ошибок. Также уровни ошибок 0 и 2 указывают, что место назначения обновлено и файлы не были скопированы.

Для чего я стою, я придумал следующее для моей простой резервной копии:

если уровень ошибки 16 Эхо-резервное копирование не удалось — см. причину выше и перейти к

если errorlevel 8 echo Все не хорошо — резервное копирование не завершено и готово

если errorlevel 4 echo Все не хорошо — некоторые файлы не совпадают и готово

если errorlevel 3 echo Резервное копирование завершено успешно и выполнено

если errorlevel 2 echo Резервное копирование уже обновлено — файлы не скопированы и готово

если errorlevel 1 echo Резервное копирование завершено успешно и выполнено

если errorlevel 0 echo Резервное копирование уже обновлено — файлы не скопированы и не выполнено

Я решил не беспокоиться о «лишних» файлах.

Я понятия не имею, что такое «несоответствующая» ошибка, потому что она еще не произошла, но я допустила ее на всякий случай.


Я согласен с гостем Джоном — вы действительно хотите указать ошибку, только если результат на самом деле 8 или выше.

поэтому для сопоставления результата robocopy с результатом 0 (успех) или 1 (сбой), подходящим для использования в задании агента SQL, я использую это:

  IF %ERRORLEVEL% LSS 8 EXIT /B 0
  EXIT /B 1

Для TeamCity я использую это, и это работает довольно хорошо. Благодаря вкладу Майка Уайетта, Дао Какао и Яна Скляренко. Мне просто нужно было увидеть полный рабочий пример, чтобы помочь визуализировать ответ.

(robocopy  .ArtifactsFitnesse %FitDestinationFolder% /MIR)
IF %%ERRORLEVEL%% LEQ 3 set errorlevel=0
IF %%ERRORLEVEL%% NEQ 0 EXIT /b %%ERRORLEVEL%%
EXIT 0


добавьте cmd / c перед этим для gitlab ci.

cmd /c (robocopy c:dirA c:dirB *.*) ^& IF %ERRORLEVEL% LEQ 1 exit 0

в противном случае EXIT 0 закрывает конвейер CI в этой точке.


Вот пример того, как скопировать готовые файлы из Visual Studio 2010+ в другую папку, так как Visual Studio ожидает 0, а не 1 на хорошей копии.

cmd /c (robocopy $(TargetDir) X:$(TargetName) $(TargetFileName) $(TargetFileName).config *.dll *.json *.xml /xx) ^& IF %ERRORLEVEL% LEQ 1 exit 0 

  • Remove From My Forums
  • Question

  • Hi All,

    I am receiving an error while copying a folder from one server to other server 

    the cmd which i am using is 

    robocopy \newftC$Newfolder \newft2C$Jyothsna /COPYALL

    the below error i am getting

    C:UsersDemouser>robocopy \newftC$Newfolder \newft2C$Jyothsna /COPYALL

    ——————————————————————————-
       ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
    ——————————————————————————-

      Started : Thu Oct 04 07:53:42 2018

    2018/10/04 07:53:42 ERROR 67 (0x00000043) Getting File System Type of Source \newftC$Newfolder
    The network name cannot be found.

    2018/10/04 07:54:04 ERROR 53 (0x00000035) Getting File System Type of Destination \newft2C$Jyothsna
    The network path was not found.

       Source — \newftC$Newfolder
         Dest — \newft2C$Jyothsna

        Files : *.*

      Options : *.* /COPYALL /R:1000000 /W:30

    ——————————————————————————

    NOTE: NTFS Security may not be copied — Source may not be NTFS.

    NOTE: NTFS Security may not be copied — Destination may not be NTFS.

    2018/10/04 07:54:04 ERROR 67 (0x00000043) Accessing Source Directory \newftC$Newfolder
    The network name cannot be found.

Answers

  • Hi,

    You have forgotten the backslashes, try this:

    robocopy \newftC$Newfolder \newft2C$Jyothsna /COPYALL

    Best regards,
    Leon


    Blog:
    https://thesystemcenterblog.com
    LinkedIn:

    • Marked as answer by

      Thursday, October 4, 2018 11:26 AM

  • Works fine for me, make sure you’re able to resolve your hostname (or use FQDN) or then try with IP address.


    Blog:
    https://thesystemcenterblog.com
    LinkedIn:

    • Marked as answer by
      Jyothsnamadanu
      Thursday, October 4, 2018 11:26 AM
  • Make sure you have administrator permissions to both source and destination computers, as you are using $ shares (which are hidden shares only viewable for administrators).

    Edit: Also make sure that NetBIOS over TCP/IP is still enabled on the relevant network adapters. 


    Blog:

    https://thesystemcenterblog.com LinkedIn:

    • Edited by
      Leon Laude
      Thursday, October 4, 2018 11:02 AM
      Added one line
    • Marked as answer by
      Jyothsnamadanu
      Thursday, October 4, 2018 11:26 AM

I’m trying to do a QNAP (linux NAS) samba shares that have about 8TB of data on it to a Windows based file server so I can properly make backups using VEEAM.

Anyways, I’ve been able to seed the 8TB fine mostly. A few hundred files of about 18 million don’t make it over.

Here is an example of my robocopy script:

    robocopy 2.168.5.80share1 z:sharesshare1 /mir /copyall /w:1 /r:2 /mir /ZB /log:z:logstf.txt /NFL /NDL /NP

Here is an example of the errors.

    2018/04/04 12:06:22 ERROR 0 (0x00000000)  2.168.5.80share1somefolder
The operation completed successfully.

I check the destination and it’s not there. My research on the issue indicates that it may be a permissions issue, and I verified the security permissions are the same as other folders that successfully copied.

I’ve been working at it most of hte day and my researching isn’t coming up with anything.

Does anyone have any suggestions on how to fix this, or another copy tool that can copy over all security permissions and such?

Thanks all!

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_cubuildoutputAdminTable_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.

I’m attempting to off-load my local SQL backups from 2 machines to a tiered storage device which will, in turn, replicate to a DR location.

Both servers are identical.

When I do the following command:

Text

Robocopy.exe $sqlProd $buProdTarget /MIR /MT /LOG:$buProdLog$source.log

I get the following:

Text

2015/08/18 08:12:24 ERROR 0 (0x00000000) ??5 \source_serverI$SQLBackupDBNameComDataLog
The operation completed successfully.

First question:  Is the /MIR command too dangerous?

Here’s what I’m trying to accomplish:

Copy local SQL backup files to backup device
3 local backups are saved on each SQL server
Remove the oldest backup filesfrom the storage device each night

It’s strange that on one server I don’t have this issue.  I could post my entire PowerShell Script but before I do that I want to make sure that the Robocopy options I’m using will do what I want.

Thanks in advance for any help.

I’m attempting to off-load my local SQL backups from 2 machines to a tiered storage device which will, in turn, replicate to a DR location.

Both servers are identical.

When I do the following command:

Text

Robocopy.exe $sqlProd $buProdTarget /MIR /MT /LOG:$buProdLog\$source.log

I get the following:

Text

2015/08/18 08:12:24 ERROR 0 (0x00000000) ??5 \\source_server\I$\SQLBackup\DBName\ComData\Log\
The operation completed successfully.

First question:  Is the /MIR command too dangerous?

Here’s what I’m trying to accomplish:

Copy local SQL backup files to backup device
3 local backups are saved on each SQL server
Remove the oldest backup filesfrom the storage device each night

It’s strange that on one server I don’t have this issue.  I could post my entire PowerShell Script but before I do that I want to make sure that the Robocopy options I’m using will do what I want.

Thanks in advance for any help.

I’m trying to do a QNAP (linux NAS) samba shares that have about 8TB of data on it to a Windows based file server so I can properly make backups using VEEAM.

Anyways, I’ve been able to seed the 8TB fine mostly. A few hundred files of about 18 million don’t make it over.

Here is an example of my robocopy script:

robocopy \\192.168.5.80\share1\ z:\shares\share1\ /mir /copyall /w:1 /r:2 /mir /ZB /log:z:\logs\tf.txt /NFL /NDL /NP

Here is an example of the errors.

2018/04/04 12:06:22 ERROR 0 (0x00000000)  \\192.168.5.80\share1\some\folder\
The operation completed successfully.

I check the destination and it’s not there. My research on the issue indicates that it may be a permissions issue, and I verified the security permissions are the same as other folders that successfully copied.

I’ve been working at it most of hte day and my researching isn’t coming up with anything.

Does anyone have any suggestions on how to fix this, or another copy tool that can copy over all security permissions and such?

Thanks all!

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.

Is it possible to ask ROBOCOPY to exit with an exit code that indicates success or failure?

I am using ROBOCOPY as part of my TeamCity build configurations, and having to add a step to just silence the exit code from ROBOCOPY seems silly to me.

Basically, I have added this:

EXIT /B 0

to the script that is being run.

However, this of course masks any real problems that ROBOCOPY would return.

Basically, I would like to have exit codes of 0 for SUCCESS and non-zero for FAILURE instead of the bit-mask that ROBOCOPY returns now.

Or, if I can’t have that, is there a simple sequence of batch commands that would translate the bit-mask of ROBOCOPY to a similar value?

asked May 7, 2011 at 13:03

Lasse V. Karlsen's user avatar

Lasse V. KarlsenLasse V. Karlsen

3,65610 gold badges41 silver badges58 bronze badges

1

As per here, Robocopy has the following exit code bits that make up the exit code:

0×10 Serious error. Robocopy did not copy any files. This is either a usage error or an error due to insufficient access privileges on the source or destination directories.

0×08 Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further.

0×04 Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary.

0×02 Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed.

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

0×00 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.

Just add if/else statements that EXIT /B 0 when the return value is 1 or maybe 0, and EXIT /B 1 otherwise. Even if files might have been copied, there’s something wrong that would need manual intervention.

Community's user avatar

answered May 7, 2011 at 13:34

Daniel Beck's user avatar

Daniel BeckDaniel Beck

109k14 gold badges287 silver badges335 bronze badges

3

TechNet suggests this one-liner to convert the exit code into a more traditional exit code:

(robocopy c:\dirA c:\dirB *.*) ^& IF %ERRORLEVEL% LEQ 1 exit 0

Or this to ignore the exit code completely (i.e. don’t care if it failed or succeeded):

(robocopy c:\dirA c:\dirB *.*) ^& exit 0

However, both commands above will terminate a script after the robocopy has executed. This is an issue especially for CI builds. If you want to use robocopy in this scenario, you need to set the error code manually for irrelevant exit codes. Below, all error codes below 8 will be rewritten to no error at all, and the script will be continued if possible.

(robocopy c:\dirA c:\dirB *.*) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0

7

Running it from Jenkins needs both ( ) and /B. If you want to ignore the error level 1,2,3,4:

(robocopy XXX YYY) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0

answered Jun 18, 2012 at 5:26

Filippo Vitale's user avatar

4

From this page you can add a section to your batch file that uses the list of error codes to output the errors and run different sections of code:

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
REM END OF BATCH FILE

x29a's user avatar

x29a

8337 silver badges10 bronze badges

answered May 7, 2011 at 13:35

Mokubai's user avatar

MokubaiMokubai

89.6k25 gold badges208 silver badges235 bronze badges

Some posters above have missed the subtlety of the bit mask. In particular paradroid has missed that errorlevel 3 indicates a completely successful copy.

Note that bit 0x01 if set indicates that some files have been copied even if there were other failures. So any odd numbered errorlevels always indicate that at least some files have been copied.
Note also that bit 0x02 simply indicates that there are files at the destination that are not present at the source. This will happen if the /E switch is used and files have been deleted from the source since a previous copy was taken. It should not happen if the /MIR switch is used because that should delete files at the destination to mirror the source (but I haven’t tested this).

So both errorlevel 1 AND 3 indicate successful copying of files with no errors.
Also errorlevels 0 AND 2 indicate that the destination is up to date and no files were copied.

For what its worth I came up with the following for my simple backup:

if errorlevel 16 echo Backup failed - see reason above & goto done

if errorlevel 8 echo All is not well - backup incomplete & goto done

if errorlevel 4 echo All is not well - some files were mismatched & goto done

if errorlevel 3 echo Backup completed successfully & goto done

if errorlevel 2 echo Backup already up to date - no files copied & goto done

if errorlevel 1 echo Backup completed successfully & goto done

if errorlevel 0 echo Backup already up to date - no files copied & goto done

I chose not to bother about the ‘extra’ files.

I have no idea what the ‘mismatched’ error is because it hasn’t happened yet but I allowed for it just in case.

Richard's user avatar

Richard

5,8719 gold badges44 silver badges74 bronze badges

answered Apr 3, 2014 at 23:56

GuestJohn's user avatar

GuestJohnGuestJohn

911 silver badge1 bronze badge

I use this:

robocopy .....
call :REPORT_ERRORLEVEL
goto :EOF

:REPORT_ERRORLEVEL
echo.
if ERRORLEVEL 16 echo ***FATAL ERROR*** & goto :EOF
if ERRORLEVEL 8 echo **FAILED COPIES** & goto :EOF
if ERRORLEVEL 4 echo *MISMATCHES* & goto :EOF
if ERRORLEVEL 2 echo EXTRA FILES & goto :EOF
if ERRORLEVEL 1 echo Copy successful & goto :EOF
if ERRORLEVEL 0 echo –no change– & goto :EOF

answered May 7, 2011 at 14:54

paradroid's user avatar

paradroidparadroid

22.8k10 gold badges76 silver badges114 bronze badges

I agree with Guest John — you really only want to indicate an error if the result is actually 8 or higher.

so to map a robocopy result to a 0 (success) or 1 (fail) result, suitable for use in a SQL Agent job, I am using this:

  IF %ERRORLEVEL% LSS 8 EXIT /B 0
  EXIT /B 1

answered Oct 24, 2014 at 3:36

Nick.Mc's user avatar

Nick.McNick.Mc

1952 silver badges11 bronze badges

For TeamCity I’m using this and it’s working quite well. Thanks to input from MikeWyatt, DaoCacao, and Yan Sklyarenko. I just needed to see a full working example to help visualize the answer.

(robocopy  .\Artifacts\Fitnesse %FitDestinationFolder% /MIR)
IF %%ERRORLEVEL%% LEQ 3 set errorlevel=0
IF %%ERRORLEVEL%% NEQ 0 EXIT /b %%ERRORLEVEL%%
EXIT 0

answered Feb 5, 2015 at 1:01

Paul Oliver's user avatar

Paul OliverPaul Oliver

2681 gold badge2 silver badges8 bronze badges

1

add cmd /c before it for gitlab ci.

cmd /c (robocopy c:\dirA c:\dirB *.*) ^& IF %ERRORLEVEL% LEQ 1 exit 0

otherwise EXIT 0 closes the CI pipeline at that point.

answered Nov 8, 2017 at 22:20

Scobber's user avatar

1

An example here on how to copy finished files from Visual Studio 2010+ to another folder as Visual Studio expects a 0 not 1 on a good copy.

cmd /c (robocopy $(TargetDir) X:\$(TargetName) $(TargetFileName) $(TargetFileName).config *.dll *.json *.xml /xx) ^& IF %ERRORLEVEL% LEQ 1 exit 0 

answered Jun 21, 2017 at 23:49

Glenn Perkins's user avatar

Here’s how I would do it:

robocopy [...] & if not errorlevel 4 ver > nul

Assuming that extra files are OK, but mismatched files are not, then exit codes 0, 1, 2 and 3 indicate success and all other indicate failure.

(Mismatched meaning we are trying to copy a file, but we can’t because there’s already a directory with the same name there.)

In batch files/cmd, exit codes set the ERRORLEVEL. To reset the ERRORLEVEL to 0 (success) we can use the fact that ver returns 0 (and discard the output). If it’s 4 or greater, we can just leave the ERRORLEVEL unchanged.

Example:

robocopy C:\temp\foo C:\temp\bar test.txt & if not errorlevel 4 ver > nul && echo Copy OK

answered Jun 16, 2021 at 9:49

johv's user avatar

johvjohv

1511 gold badge1 silver badge3 bronze badges

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

Понравилась статья? Поделить с друзьями:
  • Riello ups ошибка a61
  • Riello ups коды ошибок
  • Ricoh список ошибок
  • Robocopy коды ошибок
  • Robocopy игнорировать ошибки