Wednesday, December 31, 2008

Robocopy error: ERROR 5 (0x00000005) Changing File Attributes

I use robocopy to backup my files to a network drive with the following command:

robocopy [source folder] [target folder] /MIR

The MIR option will create the target folder as a mirror of the source folder. The command above works pretty well when both source and target folder are NTFS file systems.

When I changed the target folder to my DNS-323 network storage, which uses a Linux file system (ext2/ext3), I started getting the following errors with the command above:
  • Although some files are virtually identical in both content and timestamp, robocopy still thinks they are different and show them as "Newer". So, whenever you run the command above, robocopy will always copy these files even if they did not change (not good for incremental backups!).
  • "ERROR 5 (0x00000005) Changing File Attributes ... Access is denied".
For the first error, you need to use the /FFT flag to assume FAT file times (2 second granularity). Although the target folder is ext2/ext3, these file systems also implement file times with 2 second granularity.

For the second error (ERROR 5), you need to turn off the attribute copying. Robocopy uses the /COPY:DAT by default, which means to copy data, attributes and timestamp. You should turn off attribute copying by explicit setting /COPY:DT.

So, the command to backup from a NTFS partition to a ext2/ext3 partition should be:

robocopy [source folder] [target folder] /MIR /COPY:DT /FFT

100 comments:

Anonymous said...

Thanks for this. I've been messing around with archive bits for ages!

Anonymous said...

Thanks, this was bugging me for days

Anonymous said...

Thanks .. I've got a DNS-323 with the exact same issue, and I couldn't understand what was going on.

Anonymous said...

Thank you - now my Mirror from NTFS to FAT32 works ...

Anonymous said...

Thanks for your efforts. Saved by bacon!

Anonymous said...

Found this because of the access denied problem but also fixed the FFT flag issue - this was a 2 for 1! Thanks!

Anonymous said...

Thanks heaps...Great post.
Where would we be without articles like this.
Job well done.

Anonymous said...

Excellent post - I would mot have known where to start looking (NTFS to EXT2). Paul

Anonymous said...

Thanks I wondered what those errors were!!

Anonymous said...

Thanks a lot! :) I was going nuts trying to figure out why I could not copy files.

Anonymous said...

It was very helpfull, thanks!

Anonymous said...

Thanks a million for this! Now I can simply patch the wall from all my head pounding against it and be happy! Cheers!

Anonymous said...

Very helpful tips. had the script going in minutes. thanks much !!

Anonymous said...

Thanks a lot, saved a lot of headaches and eventually a lot of time as well!

tocsdetics said...

Thanks! It solved my problem when copy from NTFS to FAT32 external HD.

Anonymous said...

Gracias carnal. De todas las 'soluciones' que encontré, esta era la única que funcionó. -- El Guero.

Rob said...

Stumbled on your page from a google search. Robocopy to a Buffalo NAS drive kept giving the errors mentioned. Flies through now!

Cheers!

Anonymous said...

Thanks heaps. I've also got a DNS-323 with the same issue.

Anonymous said...

Luis, You DA Man! Solved problems I've been tinkering with all day.

Anonymous said...

I must echo what others have said. The Attributes think was KILLING ME until I read this. So simple, and yet...

Unknown said...

Thank you so MUCH!!!
The issue almost make me crazy,
finally I know how to fix it and it's such easy way...

Unknown said...

CANNOT thank you enough!

Anonymous said...

That totally worked and just saved me another 2 days of troubleshooting. Thank you!

Churndash said...

THANK YOU!!!!

Anonymous said...

Thank you very much !!!

Anonymous said...

Thanks Luis. I've been racking my brain with this problem for a while now. I really appreciate your taking the time to write this out so we all benefit.

Anonymous said...

Nice, I've had this problem for 1.5 years with my DNS-321. Y0U R0CK!

Paul said...

Thanks for this solution. I have been using a QNAP NAS and have been getting this error frequently for over the past year. This seems to have fixed. it!!!

Eric Minnick said...

Luis, thanks for posting this. I recently lost access to my Seagate GOFLEX Home NAS device.

I've spent all weekend trying various xcopy & robocopy combinations to get writing again.

Thanks a bunch!

Anonymous said...

Great tips, I had the exact same issue. Thanks!

Michael Urspringer said...

Thanks. Helped me with a similar problem (Error 32).

Anonymous said...

Love your work :))) made my day

Anonymous said...

Thank you!
I had this problem trying to backup files previously copied from a unix server.

Andykn said...

Thanks from me too, couldn't understand why I was getting "access denied" errors.

Anonymous said...

Great Post. Helped a lot, been scratching my head for days!

Cheers

Anonymous said...

Thanks - you just saved me some grief figuring this out.

Anonymous said...

Merci man

Anonymous said...

Legend, works perfectly

Anonymous said...

Hi - Cannot thank you enough for this, much appreciated

Anonymous said...

Thank you! Problem started to occur after I upgraded my firmware NAS and this fixed it.

Anonymous said...

worked! Thanks so much posting this!

Anonymous said...

cheers bro!! :D

Anonymous said...

Thanks man! you are wonderfull

Anonymous said...

Thank you for pointing out the attribute fix. I had the problem with NAS but not USB drives.

Anonymous said...

Second error can be eleviated by making the account a Backup Operator on the destination server if it is a Windows machine.

Anonymous said...

Thanks! Backing up to Netgear ReadyShare USB port on router. Finally worked!

Anonymous said...

GREAT !! Much thanks ! I've been struggling with these access denied stuff ! you saved some nerves

Anonymous said...

Great suggestion. Should be on top of google results for robocopy error 5 ;)

Anonymous said...

Thanks for sharing. Resolved my copying problems.

Anonymous said...

Luis -

I've tried making the change to the COPY command re removing the Attributes portion. I have full access to both the source and destination drives. However, I am still receiving the same error. Any thoughts?

Appreciation in advance for your help.


Sunil

Anonymous said...

Gracias Luis, me has dado rápida solución con esto.

Anonymous said...

Thanks luis for such stuff, I was troubleshooting the same from last 2 days....thanks

Anonymous said...

Thanks for the great info. I am trying to copy files to a mapped Windows CE drive but still get the error as well as an "Access is denied" error. Do you know any way of getting around this?

Anonymous said...

Like pretty much everyone else, your post as has solved my problem - exactly the same scenario as your initial problem. Thanks!

Jack said...

Hi Luis,
Thanks a bunch...:)
Now, I can copy from Windows to Seagate BlackArmor NAS 400.

Anonymous said...

Luis, you are a legend!

Thanks so much, been looking for an answer for this for months and you are the ONLY one that has offered a solution. Microsoft were NO help and suggested using COPY instead.

Thanks again.

// Martin

Unknown said...

Thanks man - that was really helpful. First result when I googled it. Rad.

Unknown said...

Thanks a lot man - that was really irritating me. First result when I googled it!

Anonymous said...

Thanks!

Anonymous said...

Thank you :)

Anonymous said...

changed from a FAT based NAS to a linux one and the /copy:dt fixed my errors. Thanks.

Anonymous said...

Perfect, thanks so much! Such a small change (DAT > DT) to solve such a frustrating problem!

Anonymous said...

Perfect! Thanks to you Luis for the solution of my problem and to Google for the link.

Anonymous said...

DNS-321. Problem for three years now. Robocopy would never skip same files, so no such thing as a "refresh" copy was possible. Always previously looked at robocopy without success. Very frustrating. Today, hit on looking at the DNS-321 as the issue and found this. TYVM.

Anonymous said...

Brilliant tip on the /FFT, thanks.

Anonymous said...

Thanks a bunch. Thanks also for the explanation. I feel more comfortable with advice that is explained.

Anonymous said...

Thank you!! This helped me copying files to a Terstation file server from Windows Server 2008.

- Charles

Anonymous said...

Thank you. This worked for me when I couldn't copy to a USB drive connected to a Linksys router. ROBOCOPY would give an error 5 changing attribute on the source file.

Anonymous said...

Thank you Luis!!!
This issue has been driving me nuts until I stumbled upon your post.

Anonymous said...

Thanks for hint & explanation - helps me!

Anonymous said...

Thank you for this tip Luis. I started to note this problem when I added WD My Cloud drive, which does not use NTFS format...Manu

windracer said...

Thanks for the post! I started having issues with my robocopy script on my daughter's Surface tablet after I switched from an older Buffalo LinkStation to a newer RAID version. Adding the /COPY:DT flag to my script fixed the issue.

Anonymous said...

Thank you for your blog post. You saved me a lot of frustration troubleshooting why my robocopy scripts were not working with the Buffalo NAS backup I just purchased. They are all good now.

Anonymous said...

Thanks, fixed my robocopy error to seagate NAS. You are a legend

Unknown said...

Much thanks. Funny how so many years later how this tip can be useful even still. :)

Tony Browne said...

Thanks. I way getting the file attribute error too. Works now with /COPY:DT

Anonymous said...

Thank you! Saved me from deciphering the help files.

Anonymous said...

Same here. Just got a new WD My Cloud Mirror drive which runs on unix and was running into this error. The post that keeps on giving. Thank you.

Anonymous said...

6 years later and your tip still helping people! been googling this for the last hour, tearing hair out , wondering why the NAS's own backup system is so inadequate I have to use Robocopy anyway! heard many different theorys on the error 5 thing - and you explicitly stated the cause and a very easy fix! thank you!thank you!thank you!

Anonymous said...

Thank you! Now NAS works perfectly !

Anonymous said...

Many thanks
Answered an long term issue for me

Greg B said...

Brilliant - I've been battling this one for some time now and this seems to have done the trick.

Anonymous said...

Thanks!!

Gus said...

Super helpful post! Thanks!

Nick said...

Works perfectly now, thanks!

Anonymous said...

Great - thanks! Question though: why can robocopy not change the attribs?

Anonymous said...

The gift that keeps on giving! Thank you for this post, resolved my issue (removing the A for Attributes) from my robocopy command. :-)

Ian said...

yup - this 2009 post is still helping people all over the world.. thanks (Ian - Cambridge UK)

Anonymous said...

As Ian said, 6 years and we are still fighting the good fight - thanks for this article!

Anonymous said...

Works perfectly! Great! thanks!


Unknown said...

Nice solution! Thanks!

Anonymous said...

Wow! Thanks for this tip. Was getting frustrated trying to backup data folders from a Terminal Server 2008 R2 VM to a Synology NAS and Googling the Error 5 code led me to your post, which was the only solution which worked. Thanks again!

Anonymous said...

Thank you, thank you so much.
In first position on Google search, and deserve it.

Anonymous said...

Just another thanks - it's so useful that guys like you post these little snippets!

Jean said...

Thanks an awful lot. I had been tweaking my security, creating an account with full acces, but still that depressing "access denied" message. I was going to give up and use the file explorer, but this is just plain waste of time (actually, it is not made for this kind of typical batch processes). You saved my day, like many others' before!

Anthony said...

Thanks a lot Luis. I ran into this issue with my WD "MyCloud" device.

Ahmed Ezzat said...

You Made My Day Thank You Man

Unknown said...

At last I found a post that actually helped. I only needed the /COPY:DT since my problem was the attributes.

Anonymous said...

Nice article...Thank you so much !

Anonymous said...

Thanks. This helped me trying to copy files to a WD My Cloud NAS.

Adding /COPY:DT to my Robocopy script solved the issue for me.

Spring Boot Configuration Properties Localization

Spring Boot allows to externalize application configuration by using properties files or YAML files. Spring Profiles  provide a way to segr...