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

11 comments:

Conan said...

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

Anonymous said...

Thanks, this was bugging me for days

Greg 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

Ben 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!