Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robocopy - /XA:SH - to exclude system, hidden directories?

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.

like image 204
mcu Avatar asked Apr 02 '12 18:04

mcu


People also ask

How do I exclude a hidden folder in Robocopy?

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.

Does Robocopy copy hidden folders?

1 Answer. Show activity on this post. I did some tests. did in fact copy all files and folders, regardless of their system or hidden attributes.

Why does Robocopy hide folders?

When copying from the root directory of a drive to a folder (non-root directory on a different drive), this can happen. RoboCopy may set the new directory to hidden, as it copies the system attribute of the root folder of the drive over to the new folder.

How do I exclude a file type in Robocopy?

The most important switches in this command are the /XD which allows you to exclude folders, and /XF that you can use to exclude files. The other options are optional, but you should use these options that you should use in any standard copy process using Robocopy.


2 Answers

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.

like image 121
Lasse Christiansen Avatar answered Oct 26 '22 03:10

Lasse Christiansen


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.

like image 31
Tandy Freeman Avatar answered Oct 26 '22 03:10

Tandy Freeman