How to Fix: NAS, Robocopy ERROR 5 (0x00000005) Changing File Attributes

Dennis Faas's picture

Infopackets Reader Gerry J. writes:

" Dear Dennis,

Thanks for your article on how to reset admin password on a Seagate NAS (network attached storage) - this was the only article I could find on the subject. I have a related question. I've done a full reset of the NAS (wiping out all data) and recreated my network shares, and now I'm ready to copy data back. In the past, I've used Windows file copy to do this, but sometimes it fails and then I have to start over again. I did research on this subject and it's my understanding robocopy is a much more reliable method and will actually resume the transfer if interrupted. The problem is that every time I try to copy the data back to the NAS, I keep getting an error 'ERROR 5 (0x00000005) Changing File Attributes'. I can't seem to find the answer to this and require your expertise. Can you please help? "

My response:

I asked Gerry if he would like me to connect to his machine using my remote desktop support service in order to have a closer look, and he agreed.

Below I will discuss my findings.

How to Fix: NAS, Robocopy ERROR 5 (0x00000005) Changing File Attributes

After some research, it appears that when robocopy copies files, it will (by default) attempt to store file attributes in addition to the data and time stamps on the destination media.

Since a NAS is essentially a mini Linux machine (box) with hard drives attached to it, attempting to modify file attributes will result in an error because Linux is in control of the storage and only permits limited changes to files - even while copying a file.

Therefore, the way to get around this problem is to not to copy the file attributes using robocopy's command line arguments.

For example, the following command would work:

robocopy e:\temp\ s:\ /e /copy:DT /w:1 /r:1 /v /log:"c:\temp\robocopy_copy_back_to_nas.txt"

This assumes the e:\temp\ is the source directory and s:\ is the destination (NAS). The /copy:DT switch tells robocopy to copy the data and time stamps (but not the file attributes), while /w:1 and r:/1 says to only retry a maximum of 1 times if there is an error in the file copy, with 1 second intervals between retries. The /log:"c:\temp\robocopy_copy_back_to_nas.txt" line means to make a log of the file copy and save it to c:\temp\robocopy_copy_back_to_nas.txt, while the /v switch means to log verbose errors such as skipped files or files with errors.

How to View Robocopy Log Output (Powershell)

If you want to view the log while it's copying, open up a powershell command prompt and run the following script:

Get-Content c:\temp\robocopy_copy_back_to_nas.txt -tail 1 -wait

This will provide you with a window of activity (with 1 second intervals) to see the progress. In Gerry's case it took over a week to copy the data back onto the NAS, so this was incredibly useful - plus he can parse the log file for errors if needed, described next.

How to View Robocopy Log for Errors

To scan the above log file for the word "error", you could use the following syntax via the command line (with limitations):

type c:\temp\robocopy_copy_back_to_nas.txt |findstr -i error >c:\temp\robocopy_error_log.txt

This will output any error messages to c:\temp\robocopy_error_log.txt - however you may need to open the log to find the exact reason for the error. Frankly speaking that might be irrelevant because if the file won't copy, it likely won't ever copy (due to a media error, for example). That said, it's worth looking at a few errors to see if the error messages are all the same. In that case there could be a problem with the source or possibly the robocopy arguments.

If you want a much more robust way to extract robocopy errors from the log, consider using this powershell command script as discussed on this page.

How to Log Robocopy Errors Only

If you only want to log only errors from robocopy regardless of the error reason, you can use this method:

robocopy [source] [destination] /copy:DT /w:1 /r:1 /nfl /ndl /njh /njs /ns /nc /np >> log.txt

I hope that helps.

Additional 1-on-1 Support: From Dennis

If all of this is over your head, or if you're having trouble setting up your NAS / copying files, etc - I can assist using my remote desktop support service. Simply contact me, briefly describing the issue and I'll get back to you as soon as possible.

Got a Computer Question or Problem? Ask Dennis!

I need more questions. If you have a computer question - or even a computer problem that needs fixing please email me with your question so that I can write more articles like this one. I can't promise I'll respond to all the messages I receive (depending on the volume), but I'll do my best.

About the author: Dennis Faas is the owner and operator of Infopackets.com. With over 30 years of computing experience, Dennis' areas of expertise are a broad range and include PC hardware, Microsoft Windows, Linux, network administration, and virtualization. Dennis holds a Bachelors degree in Computer Science (1999) and has authored 6 books on the topics of MS Windows and PC Security. If you like the advice you received on this page, please up-vote / Like this page and share it with friends. For technical support inquiries, Dennis can be reached via Live chat online this site using the Zopim Chat (currently located at the bottom left of the screen); optionally, you can contact Dennis through the website contact form.

Rate this article: 
Average: 5 (7 votes)