Solved

Robocopy Sntax

Posted on 2009-04-02
9
967 Views
Last Modified: 2012-06-27
I think this is a simple question, but then again if that is the case why am I asking the experts ?

I have never used Robocopy in the past, but I have come across a situation where I need to use it and I have to make sure I don't mess things up.

We currently have a 60 GB folder which contains hundreds of folders and subfolders and about 700,000 files. This files in this folder are being accessed throughout the day and people are making changes and creating new files.

We need to copy this folder to a new server. We have taken last nights backup and restored to the new server.

Tomorrow night at we are going to have everyone logoff the server we are going to disable access to the server. Then we are going to copy all files that have changed since last nights backup to the new server. after this copy the two directories should be identical , nerw server and old server. I will probablt run the windiff.exe to verify the files are the same.

My understanding of Robocopy is I can use it to copy from the source to the detination and maintain security on the files and folders.

Can anyone tell me the proper syntax of Robocopy to accomplish this task and make sure I do not delete any files from the source. I really want to make sure it is a one way copy, from source to dsestination and that it is only files that have a newer timestamp than what is already on the destination folder. Of course if the file or folder does not exist in the destination I need it created, and if the folder is empty i still need it copied.

We use EVAULT for backup and that is why I cannot do an incremental backup. I spoke to evault at length and there software does not allow you to do a restore of just files with a newer timestamp.

Thanks in advance.
0
Comment
Question by:Ekuskowski
9 Comments
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24055446
Here is the syntax for Robocopy....
http://www.ss64.com/nt/robocopy.html
 
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 250 total points
ID: 24055455
Assuming you have the new Robocopy
Use this

robocopy "G:\Main" "P:\Backup" /S /V /TS /FP /LOG+:"info.txt" /Z /R:10 /W:30

Main = The location where the files are at
Backup = The location where the files are going
info.txt = This will document everything that is copied and give all the information about the completion
Including how long it took, and if there is anything that happened during the transfer

Network
robocopy "G:\Main" "\\Server-name\Archives (P)\Main"  /S /V /TS /FP /LOG+:"Info.txt" /Z /R:10 /W:30

Same thing applies as to the 1 code.
Except this one will transfer to another computer.

Also.
When you do the first one, all others will only copy over what has been modified.

VERY IMPORTANT.
Reboot the computer after you are done.
As this takes a lot of resources, and can cause your computer to be slugish afterwards.

Good Luck
Carrzkiss



0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24055468
Forgot to mention.
The best way to get the network location is to copy it out of your Address Bar
robocopy "G:\Main" "\\Server-name\Archives (P)\Main"  /S /V /TS /FP /LOG+:"Info.txt" /Z /R:10 /W:30

The Query of the address will be something like
\\Server-name\Archives (P)\Main

Good Luck
Carrzkiss
0
 
LVL 11

Assisted Solution

by:ecsrd
ecsrd earned 250 total points
ID: 24055899
"My understanding of Robocopy is I can use it to copy from the source to the detination and maintain security on the files and folders."


The syntax to do exactly this is (and nothing more):

robocopy <source> <destination> /MIR /COPYALL

You may want to add /r:<#of retries>, /w:<wait time>, /LOG:<log name and location>, /TEE (outputs status to screen as well as log)

However, the syntax line above will do exactly what you need it to do including copying security descriptors.
0
Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24055944
ecsrd:
I do not think that you quite understand what it is that he is wanting to do.
He is wanting to copy everything over, and then copy ONLY what is modified.
Which is Exactly what my code will do.

Your code that you have supplied will copy everything over everytime.
So if the file is not newer, it will be copied anyway.
This is a wayste of time and valuable resources.

The code that I supplied does exactly what is needed.
Tested on a 300Gb drive.
Copied over through network 186Gb data.
Took 2.5 hrs
The next day, I did the same job, took about 2 minutes
To transfer over ONLY what was modified.

Have a good one.
Carrzkiss
0
 
LVL 11

Expert Comment

by:ecsrd
ID: 24056146
Actually, /MIR will only update files that have changed, it does not re-copy everything.  In fact, /MIR does exactly what you are suggesting it doesn't do.  As for /COPYALL, this switch IS needed by Ekoskowski because he needs the security descriptors moved with the file!

As a side note, the best way to accomplish EXACTLY what you are setting out to do Ekuskowski is the following syntax:  robocopy <source> <destination> /MIR /COPYALL /MON:n - where "n" is the number of changes seen before Robocopy will automatically run through and copy the changed files*.

EXPLANATION OF SWITCHES:
/MIR - Mirror a directory tree (equivalent to /E plus /PURGE) (/E = copy subdirectories, including empty ones, /PURGE delete dest files/dir that no longer exist in source)
/COPYALL - COPY ALL file info (equivalent to /COPY:DATSOU) (COPY:DATSOU = D=Data,A=Attributes,T=Timestamps,S=Security & NTFS ACLs,O=Owner info, U=aUditing info)
/MON:n = MONitor source; run again when more than n changes seen


*DON'T set it to anything less than 50, or your server will hate you because Robocopy will pretty much nnever stop running!

Additionally, your suggested syntax has some problems in it:

/E - copy Subdirectories, but not empty ones - the empty subdirectory may be there for a reason (think of C:\Temp for instance)
/TS - include source file Time Stamps in the output - slows performance of Robocopy, and only for logging, its not needed
/FP - include Full Pathname of files in the output - again only for logging, the logfile on a 60GB file transfer with this much data would take an hour to open, and would be pushing 50-60MB in size!
/LOG+ - appends to an existing log file - if the files keep changing with the previously selected /TS and /FP switches enabled over the course of a few days, that 50-60MB log file could easily eat up the entire available storage on the drive!
/Z + /R:10 + /W:30 = every single time a file is locked because it is in use, robocopy will wait, stuck on the file for 5 minutes.  If only 12 files are locked, thats a full extra HOUR of copying, and basically doing nothing.


0
 
LVL 11

Expert Comment

by:ecsrd
ID: 24056153
addendum: /Z + /R:10 +/W:30 = copy in restartable mode, retry 10 times, wait 30 seconds between retries = 5 minutes - just for clarification :).
0
 

Author Closing Comment

by:Ekuskowski
ID: 31623683
Thanks for all your help, robocopy ended up working pretty well, It was copying some files that had the same date and timestamp. So it took a little longer than we wanted. Either way since it was last minute, all of your help was great
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24065808
Glad that I could help Ekuskowski
 
Author Comments:
Thanks for all your help, robocopy ended up working pretty well, It was copying some files that had the same date and timestamp. So it took a little longer than we wanted. Either way since it was last minute, all of your help was great

--------
Using the syntax that I provided will only copy over files that timestamps are different.

Have a good one.
Carrzkiss
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now