Copying a folder with its subfolder using Robocopy

Copying a folder with its subfolder using Robocopy

I have folderA in this path: \\servernameA\sharenameA\folderA
I need to copy it under path \\ServernameB\SharenameB\FolderB

So that when I go inside \\ServernameB\SharenameB\FolderB . I shoudl see folderA with all its subfolders and files. in other words the size of folderA in the source should be the same size as in the destination.

Copy /Past did not get the same size.
I would like to use Robocopy. So what are the right switches of Robocopy that can accomplish that ?

Thank you
jskfanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Keelyn HenningIT System AdministratorCommented:
/e      Copies subdirectories. *Note that this option includes empty directories.*
0
Keelyn HenningIT System AdministratorCommented:
Or:

Mirror a directory with subfolders incl. empty directories
/MIR is an option to ROBOCOPY where you mirror a directory tree with all the subfolders including the empty directories and you purge files and folders on the destination server that no longer exists in source.

ROBOCOPY \\sourceserver\share \\destinationserver\share /MIR

Or

ROBOCOPY source-drive:\DIR destination-drive:\DIR /MIR
0
Keelyn HenningIT System AdministratorCommented:
I know this is a lot of information but here are all the options you have with Robocopy:

Option      Description
/s      Copies subdirectories. Note that this option excludes empty directories.
/e      Copies subdirectories. Note that this option includes empty directories. For additional information, see Remarks.
/lev:<N>      Copies only the top N levels of the source directory tree.
/z      Copies files in Restart mode.
/b      Copies files in Backup mode.
/zb      Uses Restart mode. If access is denied, this option uses Backup mode.
/efsraw      Copies all encrypted files in EFS RAW mode.
/copy:<CopyFlags>      Specifies the file properties to be copied. The following are the valid values for this option:
D Data
A Attributes
T Time stamps
S NTFS access control list (ACL)
O Owner information
U Auditing information
The default value for CopyFlags is DAT (data, attributes, and time stamps).
/dcopy:T      Copies directory time stamps.
/sec      Copies files with security (equivalent to /copy:DAT).
/copyall      Copies all file information (equivalent to /copy:DATSOU).
/nocopy      Copies no file information (useful with /purge).
/secfix      Fixes file security on all files, even skipped ones.
/timfix      Fixes file times on all files, even skipped ones.
/purge      Deletes destination files and directories that no longer exist in the source. For additional information, see Remarks.
/mir      Mirrors a directory tree (equivalent to /e plus /purge). For additional information, see Remarks.
/mov      Moves files, and deletes them from the source after they are copied.
/move      Moves files and directories, and deletes them from the source after they are copied.
/a+:[RASHCNET]      Adds the specified attributes to copied files.
/a-:[RASHCNET]      Removes the specified attributes from copied files.
/create      Creates a directory tree and zero-length files only.
/fat      Creates destination files by using 8.3 character-length FAT file names only.
/256      Turns off support for very long paths (longer than 256 characters).
/mon:<N>      Monitors the source, and runs again when more than N changes are detected.
/mot:<M>      Monitors source, and runs again in M minutes if changes are detected.
/MT[:N]      Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. The default value for N is 8.
The /MT parameter cannot be used with the /IPG and /EFSRAW parameters.
Redirect output using /LOG option for better performance.
Note: The /MT parameter applies to Windows Server 2008 R2 and Windows 7.
/rh:hhmm-hhmm      Specifies run times when new copies may be started.
/pf      Checks run times on a per-file (not per-pass) basis.
/ipg:n      Specifies the inter-packet gap to free bandwidth on slow lines.
/sl      Copies the symbolic link instead of the target.
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

jskfanAuthor Commented:
Can you paste the command using my paths and folders that I specified  as an example ?
Thank you
0
Keelyn HenningIT System AdministratorCommented:
ROBOCOPY \\servernameA\sharenameA\folderA \\ServernameB\SharenameB\FolderB /MIR
0
Keelyn HenningIT System AdministratorCommented:
And just a side note, I really like FreeFileSync over Robocopy. My easy to configure and faster in the transfer. And the best part about it is it's free!
0
MaheshArchitectCommented:
The correct syntax would be:
robocopy.exe "\\servernameA\sharenameA\folderA" "\\ServernameB\SharenameB\FolderB\FolderA" /e /copyall /zb

Open in new window


This will ensure that folderA on server A and all sub folders will get copied under folder on server B with all permissions
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jskfanAuthor Commented:
Mahesh,
robocopy.exe "\\servernameA\sharenameA\folderA" "\\ServernameB\SharenameB\FolderB\FolderA" /e /copyall /zb


when I go to folderB, I see all contents of folderA inside folderB. what I asked for was when I go to folderB, I should find just folderA, then I can open folderA and find all the subfolder and files .
0
MaheshArchitectCommented:
so I have provided command what you have asked for:

I have tested and it working as expected

Ex:
\\robocopy \\srv1\share1\fd1 \\srv2\share2\fd2\fd1 /copyall /e /zb
The command should copy "fd1" under "fd2"
0
jskfanAuthor Commented:
Sorry Mahesh,

I guess I typed:
robocopy.exe "\\servernameA\sharenameA\folderA" "\\ServernameB\SharenameB\FolderB\" /e /copyall /zb
0
jskfanAuthor Commented:
Thank you
0
MaheshArchitectCommented:
NP Sir..

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.