Robocopy Directory Failure

13 November 2018

I was using Robocopy.exe on a live server to backup files to a remote share every day. In task scheduler the robocopy tasks returned with a code of 8, meaning

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

and indeed the log file had something like this:

            Total    Copied   Skipped  Mismatch    FAILED    Extras
 Dirs :     13796         1     13794         0         1         0
Files :   4011310     14482   3996828         0         0         3
Bytes : 283.661 g   1.378 g 282.283 g         0         0    33.9 k
Times :   0:15:15   0:08:03                       0:00:00   0:07:12

There is a failed directory copy, but even with full logging enabled, robocopy wouldn't tell me which directory it was.

At this point one option would be to start up Process Monitor and check for failing file access, but this being a busy live server, this wasn't really and option because it does slow down the system a bit.

So I wrote a quick PowerShell one-liner:

ls K:\data\ -Directory | % { robocopy $_.FullName $home *.x6t /NDL /S /NP /R:1 /W:1 /Log+:$Home\test.log}

Note the *.x6t, a file extension that does not exist at all on my server, so nothing is ever copied.

Now I could review the log file and search for something like

      0         1         0

or better using the regular expression:

 +(\d+ +) (\d+ +)(\d+ +)(\d+ +)[1-9]+[0-9]* +\d

just above the match line I could see the parent directory, in my case 'export-2017', now I started with that root:

ls K:\data\export-2017 -Directory | % { robocopy $_.FullName $home *.x6t /NDL /S /NP /R:1 /W:1 /Log+:$Home\test2.log}

I reviewed the log file again and continued the same way until I finally found an error message:

2018/11/13 20:29:22 ERROR 5 (0x00000005) Accessing Source Directory K:\data\export-2017\05\20\ Access is denied. 

I fixed the permissions on that directory and from now on they Robocopy process worked just fine.

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows