Why doesn't XCOPY copy my junctions?
I'm trying to copy a Users Directory with XCOPY, but parts of it are not working.
(I'm running as Administrator, in a command prompt which was started with Run As Administrator)
The user directory looks like: (abbreviated)
> dir /a /q
05/18/2014 05:42 PM <DIR> MyPC\JoeBob AppData
05/18/2014 05:42 PM <JUNCTION> NT AUTHORITY\SYSTEM Application Data [C:\Users\JoeBob\AppData\Roaming]
05/18/2014 05:42 PM <DIR> MyPC\JoeBob Contacts
05/18/2014 05:42 PM <JUNCTION> NT AUTHORITY\SYSTEM Cookies [C:\Users\JoeBob\AppData\Roaming\Microsoft\Windows\Cookies]
05/18/2014 05:42 PM <JUNCTION> NT AUTHORITY\SYSTEM Local Settings [C:\Users\JoeBob\AppData\Local]
05/18/2014 05:42 PM <DIR> MyPC\JoeBob Music
05/18/2014 05:42 PM <JUNCTION> NT AUTHORITY\SYSTEM My Documents [C:\Users\JoeBob\Documents]
05/18/2014 05:42 PM <JUNCTION> NT AUTHORITY\SYSTEM NetHood [C:\Users\JoeBob\AppData\Roaming\Microsoft\Windows\Network Shortcuts]
05/18/2014 09:31 PM 786,432 MyPC\JoeBob NTUSER.DAT
05/18/2014 09:31 PM 262,144 NT AUTHORITY\SYSTEM ntuser.dat.LOG1
05/18/2014 05:42 PM 0 NT AUTHORITY\SYSTEM ntuser.dat.LOG2
05/18/2014 09:31 PM 65,536 NT AUTHORITY\SYSTEM NTUSER.DAT{016888bd-6c6f-11de-8d1d-001e0bcde3ec}.TM.blf
05/18/2014 09:31 PM 524,288 NT AUTHORITY\SYSTEM NTUSER.DAT{016888bd-6c6f-11de-8d1d-001e0bcde3ec}.TMContainer00000000000000000001.regtrans-ms
05/18/2014 09:31 PM 524,288 NT AUTHORITY\SYSTEM NTUSER.DAT{016888bd-6c6f-11de-8d1d-001e0bcde3ec}.TMContainer00000000000000000002.regtrans-ms
Note that:
- Some of the directories are really junctions (aka. symlinks / reparse points)
- The junctions have owner
NT AUTHORITY\SYSTEM
.
When I run the command:
xcopy C:\Users\JoeBob\*.* E: /O/X/E/H/K/B
the various switches are supposed to do:
-
/O
- Copy Ownership info -
/B
- Copy Symlink
But when I actually do the copy, and view the results at the destination E:, all the Junctions have become real directories, and have owner BUILTIN\Administrators
It seems that switches /O
and /B
both failed.
But I cannot find any mention that those switches don't work for SYSTEM-owned junctions.
Am I missing something? Is there a good fix or workaround for this?
Solution 1:
I think your mixing a directory Symbolic link
with directory Junction
.
A directory Junction is very different from a directory symbolic link (Symlink). XCOPY
does copy Symlinks correctly (with /B
) but it can't handle directory Junctions. (See an explanation of all these types here)
You can copy the directory with Robocopy and exclude the directory Junctions (with /XJ
) but then you don't have those junctions in your backup. You could Google for it: windows copy junction points.
This way i found this topic with a possible solution of using the tool FastCopy which would preserve the junction points.