Robocopy Sntax

Posted on 2009-04-02
Medium Priority
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.
Question by:Ekuskowski
LVL 14

Expert Comment

ID: 24055446
Here is the syntax for Robocopy....
LVL 31

Accepted Solution

Wayne Barron earned 1000 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

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.

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

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

LVL 31

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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 11

Assisted Solution

ecsrd earned 1000 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.
LVL 31

Expert Comment

by:Wayne Barron
ID: 24055944
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.
LVL 11

Expert Comment

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*.

/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.

LVL 11

Expert Comment

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 :).

Author Closing Comment

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
LVL 31

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.

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses

589 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