Link to home
Start Free TrialLog in
Avatar of Thor2923
Thor2923Flag for United States of America

asked on

Robocopy without writing over pre copied folders or files

I need to run robocopy to copy several TB of data from my server to another. Someone before was trying to drag and drop and had timeout issues and I think he may have also had permission problems. I want to run it tonight once and for all. I do not want to write over anything that has already been copied, I need to copy all folders, subfolders and files and I am a domain admin. I want to log into my target server and run something like this:

C:\Robocopy \\server1\Folder\sourcefoler E:\folder\targetfolder /S /?  

I do not want to have to run this again, I am hoping it will skip any files that do not copy and continue until everything is done. I do not care of empty folders are copied or not. All suggestions welcome. I am asking on here because I do not want to get a switch wrong and hope it can be done once and for all tonight. Too many people have already tried to make this happen...thanks
ASKER CERTIFIED SOLUTION
Avatar of Travis Martinez
Travis Martinez
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll also add that the /MIR option will copy empty directories and file attributes as well.
It may be wise to also use these switches:
/dcopy - to copy the folder timestamps. Else, it will have the current time.
/log+:filename.txt (append to existing log) or /log:filename.txt (overwrite existing log) - logging is helpful for reviewing what happened
Either I'm confused (certainly possible) or /MIR works differently from what is being described here.  The help screen states: "/MIR :: MIRror a directory tree (equivalent to /E plus /PURGE)".  The key here is that it removes files in the destination that don't exist in the source.

Doesn't Robocopy, by default, skip files where the source timestamp is the same or older than the destination?  I think that's what the OP wants.

I agree with the use of /R though I'd also /w:2 (only wait 2 seconds instead of the default 30 before retrying) and also agree with /dcopy and /log....
do not want to write over anything that has already been copied
In that case, don't use /mir. /S should be fine. Do you need the permissions copied also?
Mirror will not purge everything automatically but yes it will remove a file in the target directory if it does not exist in the source.  Anything that exists in the target directory that has the same file size and timestamps as the source will be skipped and not copied.

It's a question about what needs to be preserved in copy.
All above are very good examples. I do think you will need to rerun it a few times to catch all files.

Here is my normally go to switches:
robocopy "\\server1\Folder\sourcefoler"  "E:\folder\targetfolder" /S /XO /W:0 /R:0  /COPYALL /DCOPY:DAT  /log:C:\temp\logfile.txt /NP  

Open in new window

the /NP is key if you do not want a log file that balloons.  If you do not care about the files be logged and all you want to see if the final results you can use /NFL /NDL switches
robocopy "\\server1\Folder\sourcefoler"  "E:\folder\targetfolder" /S /XO /W:0 /R:0  /COPYALL /DCOPY:D  /log:C:\temp\logfile.txt /NP /NFL /NDL 

Open in new window

Then I rerun it until there are no more files that need to be copied.

Edit: /E = all sub-directories (including empty) /XO= exclude Older files.  If the file in the destination matches the source it is skipped.  
The rerun take a fraction of the time.  I had 300 GB first run take hours and the additional passes took minutes.
Avatar of Thor2923

ASKER

copy is still running but going beautifully ....thanks
Grad to hear.