dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
9
share rss forum feed

dave
Premium,MVM
join:2000-05-04
not in ohio
kudos:8
reply to koam

Re: [WIN7] Copy complete directory tree

/SL might help

/SL :: copy symbolic links versus the target.


We're dealing with junctions rather than symbolic links, but they have similarities...


koam
Pink Pecker
Premium
join:2000-08-16
East Puddle
Reviews:
·Shoreham Telephone
Thanks. I also found this: »answers.microsoft.com/en-us/wind···e4d27232

"Short answer: If you're using Robocopy, simply using the /XJ switch will avoid this problem.
Long answer:
This recursive file structure is indeed caused by the implementation of junction points in the NTFS file structure by Microsoft. Essentially, some "folders" are not actual folders at all, but junction or reparse points, which essentially reroute a directory name to another directory. This is much like mapping a drive letter to a directory or another drive, and the Windows system is designed to handle this NTFS structure situation behind the scenes.
In Vista and 7, Microsoft decided to standardize some of the typical Windows settings for users, documents, etc., which had varied over time. To maintain backward compatibility, the old standards were also retained BUT WITH JUNCTIONS REPARSING THEM TO REDIRECT INQUIRIES INTO THE NEW ACTUAL DIRECTORIES. Most programs work right through these junctions without even noticing. For example, C:\Documents and Settings points to C:\Users. Even though the former directory does not actually exist, it APPEARS to have the files and directories under the latter, and a change in the contents of either directory will be reflected in the other, since they are in fact, a single directory.
The difficulty comes from certain Reparse Points which essentially redirect to a parent directory. This causes a recursive cascade for unwary programs or users who are unaware of the proper handling of the junctions (even though the junctions are designed to be transparent to software looking for either directory). The usual "subdirectory explosion" situation comes from the fact that the \Documents and Settings\$USER$\Application Data folder (consistent with XP convention) is a junction point in Vista to \Users\$USER$\AppData\Roaming, which in turn can contain the Application Data junction as a subdirectory...
Under normal Windows permissions, the junctions and their directories are inaccessible and hidden. If permissions are changed or programs working outside Windows are not prepared to encounter these junctions, duplication and recursion is destined to occur. For those using powerful low-level command interfaces such as Repair Console, it is best to check the capabilities and switches on the commands by using the /? help switch (for example, Robocopy /?, xcopy /?, rd /?, etc.). If you are not sure what you are doing, be sure to backup ahead of time with a reliable Windows program, with proper use of Restore Points.
Another useful discussion is here: »www.vistax64.com/vista-general/5···ory.html "
--
YOU can help reduce poverty, sustainably.
»www.kiva.org/lender/kenandart

dave
Premium,MVM
join:2000-05-04
not in ohio
kudos:8
Short form: the guy who authorized loops in the directory structure should be held accountable under "cure is worse than the original disease" regulations.

OZO
Premium
join:2003-01-17
kudos:2
Agreed. It was not smart decision at all


koam
Pink Pecker
Premium
join:2000-08-16
East Puddle
reply to dave
I now have to do the purge thing because I can't delete all of Y:\Users from either Windows or Administrator command prompt.


koam
Pink Pecker
Premium
join:2000-08-16
East Puddle
Reviews:
·Shoreham Telephone
To purge the extra files:

This really solve the problem you have. The correct syntax is:
robocopy c:\purge d:\users /purge
where "d:\users" is the infinite loop path
Also make sure to create a blank folder named "purge" in c:\ as mentioned above
Run the robocopy command a few times until it delete all the copied folders. It works for me.

I used
robocopy y:\purge y:\users /purge
in the administrator command window
and it cranked for 20 seconds, deleting 401 Extras Folders, and 2595 Extras Files.
--
YOU can help reduce poverty, sustainably.
»www.kiva.org/lender/kenandart


koam
Pink Pecker
Premium
join:2000-08-16
East Puddle
Reviews:
·Shoreham Telephone
reply to dave
Now I'm trying

robocopy c:\Users y:\Users /mir /sl /xj

but it's hanging because it says that the ntuser.dat file is in use by another process.

Do I have to boot up to DOS or something? (how?)
--
YOU can help reduce poverty, sustainably.
»www.kiva.org/lender/kenandart

dave
Premium,MVM
join:2000-05-04
not in ohio
kudos:8
Reviews:
·Verizon FiOS
You can't open a file for which the current opener has said he wants exclusive access. The end. Your only choice is for the copy program to (a) fail, or (b) skip that file.

/R:a-small-number might help.

ntuser.dat is the current user's registry, so assuming you can figure out how to skip it, it might be worth creating a special user for this backup, so that the normal user gts copied correctly.

(There is no 'DOS' anyway).

SipSizzurp
Fo' Shizzle
Premium
join:2005-12-28
Houston, TX
kudos:4
reply to koam
said by koam:

but it's hanging because it says that the ntuser.dat file is in use by another process.

Dave was correct, you need to skip files that are locked. Here is from the help file ;

/R:n :: number of Retries on failed copies: default 1 mill
/W:n :: Wait time between retries: default is 30 seconds.


This is some of what my batch files typically have to include sub directories. This will also re-try locked files after one second and only once before moving on.

/S /W:1 /R:1

reply to dave
Is it because of backward compatible of previous Windows software?


koam
Pink Pecker
Premium
join:2000-08-16
East Puddle
Reviews:
·Shoreham Telephone
reply to dave
Thanks all.

Does anyone know if this is likely to work?

»www.kavoir.com/2012/07/how-to-fr···asy.html
--
YOU can help reduce poverty, sustainably.
»www.kiva.org/lender/kenandart

dave
Premium,MVM
join:2000-05-04
not in ohio
kudos:8
Reviews:
·Verizon FiOS
reply to RazzyInfLoop
said by RazzyInfLoop :

Is it because of backward compatible of previous Windows software?

Because of previous mostly-3rd-party software that used hardwired paths.

But here's the design tradeoff. Do you want:

a) Problems with old apps written by people that don't know how to avoid hardcoded path names - which was always bad practice.

b) Problems in old apps that don't expect loops in file systems - which has never happened before.

In order to avoid people having (a), Windows has exposed (b). I think this was the wrong choice. I'd go further: a loop in a file system is never ever the right choice.

Note, it's not junctions per se I'm complaining about, it is using junctions in such a way as to make loops.


Razzy12345

@rr.com
said by dave:

said by RazzyInfLoop :

Is it because of backward compatible of previous Windows software?

Because of previous mostly-3rd-party software that used hardwired paths.

But here's the design tradeoff. Do you want:

a) Problems with old apps written by people that don't know how to avoid hardcoded path names - which was always bad practice.

b) Problems in old apps that don't expect loops in file systems - which has never happened before.

In order to avoid people having (a), Windows has exposed (b). I think this was the wrong choice. I'd go further: a loop in a file system is never ever the right choice.

Note, it's not junctions per se I'm complaining about, it is using junctions in such a way as to make loops.

I understand the needs of using links for poor coding but I'm asking this because you can do the same thing in Linux. Is it avoidable?

dave
Premium,MVM
join:2000-05-04
not in ohio
kudos:8
Reviews:
·Verizon FiOS
The avoidance mechanism is "it's stupid, don't set it up like that".

If the question was about detecting stupidity...

If you own code that need to traverse the file system, you can likely do your own loop detection ("this is a symlink, have I seen it before in this path?").

I believe Posix systems place a limit on the number of symbolic links the kernel will traverse in path resolution. Offhand, I'd suppose that could work in Windows too.

SipSizzurp
Fo' Shizzle
Premium
join:2005-12-28
Houston, TX
kudos:4
reply to koam
said by koam:

Does anyone know if this is likely to work?

You should have stated your objective in the first post. I needed to move profiles in W7 so I could use Deep Freeze on the C: drive. I did this a couple of years ago, so my memory of the event is not very fresh. Here is the process I was able to condense after reading the 3 tutorials linked below. You might find some new tips in those tuts.

Using Registry Editor
To accomplish this using Registry editor, follow these steps:

· Create the destination folder first

· Click Start, Run and type Regedit.exe

· For per-user special folders, navigate to the following location:

HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ User Shell Folders

· For per-system special folders, navigate to the following location:

HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ User Shell Folders

· Double-click the corresponding shell folder name

· Change the Value data accordingly, mentioning the destination path

· Close Regedit.exe

. In Safe Mode, "Move" the user data folders from the original folder to the new folder using Windows "Drag and Move". When prompted about the .ini files tell it to move them too.


The final "Move" operation is performed in safe mode while logged into a different profile than the one you are moving.

Links ;
http://social.technet.microsoft.com/forums/en-US/itprovistasetup/thread/91aa8b26-2b09-4e56-955c-679b297832e1/

http://www.starkeith.net/coredump/2009/05/18/how-to-move-your-windows-user-profile-to-another-drive/

http://answers.microsoft.com/en-us/windows/forum/windows_7-files/win7-how-do-i-move-user-folder-to-a-different/565f16a5-e5ed-43c9-8422-4f56aebb296e