12

It seems to only work on files. Or am I doing something wrong?

I tried backing a user folder (C:\Users\XXX) in Vista, which has a bunch of hidden/system folders. I used /XA:SHT

The folder 'AppData' is 'hidden' but NOT 'system', so it was not excluded.
Other special folders were 'hidden' AND 'system', and they were excluded. But I am not sure it was because of the /XA:SHT switch I used or some other reason, like permissions.

So, my question is, does /XA applies to directories also, or files only? I hope I don't have to manually enter all the special folders with the /XD switch.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
mcu
  • 3,302
  • 8
  • 38
  • 64

4 Answers4

23

According to the documentation /XA does only apply to files.

eXclude files with any of the given Attributes

And just to be sure - I have just tested with Robocopy on Windows 8 RTM and the flag /XA:SH does not make Robocopy ignore hidden directories.

I'm also using Robocopy to do regular backup of my user directory, and to exclude directory junction points ( like My Music ) I use the /XJD flag. Also, to avoid AppData getting copied I use the /XD flag.

My complete list of arguments looks like this: /MIR /FFT /Z /XA:SH /R:0 /LOG+:path\to\logfile.txt /TEE /XJD /NP /XD AppData

For argument reference, please see the documentation.

Lasse Christiansen
  • 10,205
  • 7
  • 50
  • 79
  • 6
    I put in a feature request using the Windows 10 "Windows Feedback" app. If you open Windows Feedback and search for "robocopy exclude system directories", it should be at the top of the list. Please upvote it, and maybe we can get Microsoft to make robocopy all the more robust. – Mark McClelland Mar 23 '16 at 08:45
1

You can try to use the /XD parameter in order to exclude a directory based on a pattern. I've found that using /XD *. excludes directories with dots. I combine it with XA:SH in order to also exclude hidden files.

Tandy Freeman
  • 528
  • 5
  • 15
1

To ignore all hidden directories just add this flag:

/XD .*
ABC
  • 71
  • 9
0

You can also /SAVE:jobname that contains all the switches you want set. The JOB file is just a text file, so you can edit it to remove source and destination, or make later changes. Then your command line would look like:

robocopy source destination /JOB:jobname

You will get all the settings you prefer, without having to re-type them every time. So doing a /XD for System Volume Information and the Recycling Bin are super easy as they pre-exist in the JOB. Do it for all the directories you want to exclude. Not to mention all the switches you use. Even create Jobs for specific Drives.