Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When using robocopy windows utility, what flags do I set so that robocopy aborts on the very first error it sees, similar to xcopy /dry command?

I need to mirror two dirs, and on occasion some files would be locked. I do not want robocopy to continue trying to copy files, or override the files that are not locked - rather the very first error should stop the whole copy process.

share|improve this question

3 Answers 3

You're going to have to use a batch file and robocopy exit codes

share|improve this answer
    
for that, the robocopy has to exit first! Please re-read the question. –  Yurik Oct 19 '09 at 21:59

I think you're not going to find an easy way to do this with Robocopy alone - it doesn't have a switch to exit on failures.

Xcopy is a lot less capable but by default it does fail in the way you want as you've pointed out. What you could do is run XCopy and if it terminates with errorlevel 0 (success) then you could then run Robocopy to carry out the purge function. This isn't going to deal cleanly with some edge cases, but it will behave the way you want for the most part.

share|improve this answer
Robocopy "C:\Source\" "C:\Destination\" *.* /V /S /E /COPY:DAT /R:1 /W:0 > log.txt

Output:

Source : C:\Source\  
Dest : C:\Destination\  
Files : \*.*  
Options : \*.* /V /S /E /COPY:DAT /R:1 /W:0
...

The /R:1 option sets the retry attempts to 1 and the /W:0 sets the wait time to 0. Other options that I used were:

  • /S Copy subfolders
  • /E Copy subfolders, even empty ones
  • /V Produce verbose output showing skipped files, errors, etc.
  • /COPY:DAT Copy data, attributes and time stamps which is the default anyways
  • > log.txt Pipes output to a text file for later inspection.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.