Robocopy Sntax

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.
Who is Participating?
Wayne BarronAuthor, Web DeveloperCommented:
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

Here is the syntax for Robocopy....
Wayne BarronAuthor, Web DeveloperCommented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

"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.
Wayne BarronAuthor, Web DeveloperCommented:
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.
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.

addendum: /Z + /R:10 +/W:30 = copy in restartable mode, retry 10 times, wait 30 seconds between retries = 5 minutes - just for clarification :).
EkuskowskiAuthor Commented:
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
Wayne BarronAuthor, Web DeveloperCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.