Avatar of DP230
DP230Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Using robocopy to retain subfolders, shared names and permissions?

Dear Experts, we need to copy about 800 GB shared data from VM to physical machine (via network). We intend to use robocopy (option  " /sec + /mir + /e " so that all subfolders, permisions will be retained. However, the shared names were lost (for example: \\shared_IP\test$)

So, can we have solution for this? we'd like to retain all subfoders/tree, their permissions and shared names. Many thanks as always!
VirtualizationWindows Server 2012Windows NetworkingActive Directory* Data Migration

Avatar of undefined
Last Comment
serialband
Avatar of serialband
serialband
Flag of Ukraine image

The /e is redundant and unnecessary with /mir (which is /e /purge)

What do you mean by shared names being lost?  if you're copying from the share to a folder, you can create a folder to mach a share name.  If you meant add permission to folders, then you need to add the /dcopy option

robocopy /sec /mir /sl /xj /r:0 /w:0 /dcopy:dat  \\shared_IP\test$ D:\server_folder\test_share\
Avatar of FOX
FOX
Flag of United States of America image

remove /sec as /copyall will get all your permissions

YOu want to use the switches  /e /copyall /dcopy:dat /Mir /TEE /log+:"c:\filepath\robocopy.log"
ASKER CERTIFIED SOLUTION
Avatar of Hello There
Hello There

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of DP230
DP230
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

@HelloThere: what are the purposes of initial copy and final copy?


Avatar of Hello There
Hello There

Initial copy - you copy all
Final copy - you copy the difference (new files, changed files)

Avatar of serialband
serialband
Flag of Ukraine image

You really should change the settings to /r:0 /w:0.  You waste a lot of time if files are open and in use, especially if it's an initial copy.  You should really just run robocopy again to get those files rather than doing those retries right then.  The in-use files aren't likely to close in 30 seconds, and you've just delayed the copy tremendously with /r:6 /r:5.  I've always set it to /r:0 /w:0 and just ran robocopy again, because files that were opened during the first pass are more likely to be closed hours later than 30 seconds later.

If you're doing a file server migration, you can run robocopy multiple times and catch missed files that way.  Then schedule downtime and do a final robocopy and you'll be done quicker, with a much shorter downtime.


Avatar of DP230
DP230
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

@Hello there, I have to share a folder via network as a destination, however after copied all files, when I deleted the share features of that shared folder, all subfolders (which were rebocopy from OLD server) were lost the shared name and permissions.
Avatar of DP230
DP230
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

For example:

OLD server: the shared name is: \\OLD_IP\HCNS\BANNS1$ (in G drive)

I did these steps:
1. Backup registry of old server
2. Create a shared folder in NEW server: \\NEW_IP\HCNS$
3. Robocopy:
robocopy.exe "G:\HCNS" "\\NEW_IP\HCNS$
" /e /b /copyall /r:6 /w:5 /MT:64 /tee

Open in new window

4. TurnOff the share in new server

Avatar of FOX
FOX
Flag of United States of America image

Leverage icacls to recopy the acl permissions and reapply them to the new destination
http://virot.eu/save-and-restore-ntfs-permissions-using-icacls/
Avatar of serialband
serialband
Flag of Ukraine image

Did you load the full registry share settings?

As for the robocopy:

You left off /dcopy:dat to copy the permissions of the directories.  The /copyall (/copy:datsou) only copies file permissions and may give you errors on the sou part depending on what permissions group settings you have.  You may have to be added to Backup Operators.  You can also use icacls if you skip the sou options.

Do you actually have 64 threads on your system?  You should change that to the number of threads your system actually have.  You may want to subtract one so that you have 1 process available for other services.  There's no point in having /mt:64 if you don't have 64 threads available to you.  All the other allocated threads will just be stalled and waiting until a cpu thread is freed up.

You don't need the /tee if you're not splitting the output to a logfile.  Also, if you're going to send it to logfile, you don't really need to send it to the console.  It will run a little bit faster if it's not sending output to a display at the same time.

Again, you should set retries and wait to /r:0 and /w:0 if the file server is a live server, because you will massively delay the initial copy when users have files open.  You should just copy without any waits, and just run another robocopy afterwards.  Users aren't going to close their files in that short of time.

You should also use /sl /xj to avoid copying over links and junctions as a duplicate copy and exploding your copy size.

robocopy /e /copyall /dcopy:dat /r:0 /w:0 /xj /sl  G:\HCNS \\NEW_IP\HCNS$

You should always do the copy from the newer OS, because the newer version of robocopy has more options.  If you don't have these options, then get a copy from someone with Windows 10 or Server 2012 or newer.  You can copy the newer version down and it will work.  The robocopy program is a self contained executable that came separately in a resource kit back in Server 2003 and I initially copied those everywhere, back down to Server 2000.  When Windows 7 came out and had the /mt option, I copied that to all the old servers so I could stop opening separate command prompts to have manually have multiple threads running.


Avatar of DP230
DP230
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

User generated image
There is a folder which its files are skipped. Can you explain?
Avatar of Hello There
Hello There

Check the log file.
Avatar of serialband
serialband
Flag of Ukraine image

Do those folders and files already exist in the destination?  If they do, they will be skipped.  This saves a lot of time over drag and drop, and lets you copy just the changes.  
Active Directory
Active Directory

Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.

86K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo