?
Solved

Robocopy - correct switches to use

Posted on 2009-06-30
9
Medium Priority
?
686 Views
Last Modified: 2012-05-07
I have been trying out Robocopy to do some archiving work.
The version of Robocopy I am using is v5.1.1.1010 (don't know if there is a more up to date version)
I tried what I consider to be a basic command (in a batch file) as follows;

robocopy "N:\IT\Temp\Test" "R:" /E /COPYALL /V /NP /LOG:"robo-test-copy-log.txt" /R:10 /W:30

Extract from the log file shows that 3 files were copied, but no directories.
See below
------------------------------------------------------------------------------
                Total    Copied   Skipped  Mismatch    FAILED    Extras
     Dirs :         1         0         1         0         0         9
    Files :         3         3         0         0         0         6
    Bytes :    60.5 k    60.5 k         0         0         0   39.42 m
    Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   What has happened was that although the Source has the files 3 levels below the root (N:), the copied files were all stored in the root of the Destination (R:).
I had expected the sub-folders to be re-created on R: which did not happen.
I have since tried /S and /CREATE . Even /MIR although I have no wish for source files to be purged after the copy.

I would appreciate if some experts could point out the errors in the command.
Thanks
0
Comment
Question by:garychu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24751669
this will give you everything. This is what I use, (Copy)

robocopy "C:\Documents and Settings\" "D:\Backup\Documents and Settings\" /S /V /TS /FP /LOG+:"Documents&Setting.txt" /Z /R:10 /W:30

And I am using the same version as you are as well.

Good Luck
Carrzkiss
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24751673
sorry. to many slashes


robocopy "C:\Documents and Settings" "D:\Backup\Documents and Settings" /S /V /TS /FP /LOG+:"Documents&Setting.txt" /Z /R:10 /W:30

Carrzkiss
0
 

Author Comment

by:garychu
ID: 24759998
Thanks, Carrzkiss.
Sorry if I did not explain the issue well enough.
robocopy "N:\IT\Temp\Test" "R:\IT\Temp\Test" /E /COPYALL /V /NP /LOG:"robo-test-copy-log.txt" /R:10 /W:30
works perfectly just like you demonstrated in your example.
It is when the full path is not stated for both Source and Destination that I hit a problem.
It is not always convenient to have to pre create the destination directory structure in advance (using /CREATE I presume, without having tried it yet).
Thus I had used
robocopy "N:\IT\Temp\Test" "R:" /E /COPYALL /V /NP /LOG:"robo-test-copy-log.txt" /R:10 /W:30
instead, thinking that the /E switch will create the necessary folders. Introducing the /MOV switch also did not make a difference.
Robocopy is such a powerful tool. It can't be so dumb in this respect. So my guess is I have not used the correct switches (or event sequence of switches for all I know!)
Thanks again for your interest in this question.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24760035
OK
Are you stating that you want the directory structure to be created into the new drive as such:

R:\IT\Temp\Test

Sorry, you will have to put in the pre-defined destination path.
Just like my example.

Sorry, but I do not think that it will do it without that information, But I could be wrong.
But I have been using RoboCopy for about 5 yrs now, and I have never seen anything as
To what you are wanting.

Good Luck
Carrzkiss

0
 

Author Comment

by:garychu
ID: 24768149
Thanks again, Carrzkiss.
Actually I do not think my requirement is all that unique and unusual.
Consider this scenario.
I have a folder on a file-server with a large number of sub-folders and files. Changes to directory structure, addition/deletion of sub-folders happen all the time.
I wish to use robocopy to move files of a given age to another disk volume prior to being archvied. But I need to have the original (source) directory structure preserved.
It would be quite impractical to have to manually create empty sub-folders each time in advance of the move.
I have tried the /CREATE switch - but it does not seem to work as I have expected it to.
Perhaps you can suggest a suitable command line making use of the /CREATE switch which should also help in my situation.
0
 
LVL 31

Accepted Solution

by:
Wayne Barron earned 1500 total points
ID: 24769214
You do not create the "Empty Sub Folders"
Example
"N:\IT\Temp\Test"
The above is your structure of the folder directory correct? Right.
OK.
Now, you want to copy the files over to the archive drive like so
"R:\IT\Temp\Test"
No, you do not phisically have to create the folders.
The program does that for you.
YOU HAVE to write the directory structure out within the script.
If not, then lets say you do this.

"R:\Archive"
Now, you point it to that archive, and it is going to dump straight into there, and list all the folders that
Are in \Test
Now
You write it out as:   "R:\Archive\IT\Temp\Test"
Then it is going to drop all the contents into here.
And thus keeping your folder structure the same.

---------
Now.
Source
"N:\IT\Temp\Test"
Desitination
 "R:"
With some switches thrown, will still NOT create that Structure of:  R:\IT\Temp\Test
Not without having it written out within the script as I have done above.

Good Luck
Carrzkiss
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24769223
Did some reading on the /CREATE
And it suppose to ONLY create the Folder structure only.
But seems that it does not quite work as expected.

I will test it later on if I have the time.
Right now I am trying to get a web site finished and released.
As it seems that it is taking longer then expected.

Good Luck
Carrzkiss
0
 

Author Comment

by:garychu
ID: 24774982
Yes - I think I have got it.
Robocopy copies everything that is in a folder (if not excluded). In effect this means including sub-folders and files if the /S or /E switches are used.
Thus in my example, I should have used just N:\IT as source and R: as destination.
All items within N:\IT will be created, including empty sub-folders completely in R:

Thanks again for the patience and time taken to explain the issue.
Good luck on your website!
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24775444
Not a problem
Hope it all works out for you.
(Why the B though?)

And thanks for the Luck
I am going to need it.
I am going to spend the entire weekend on it, and "Try" to take some time off tomorrow
To spend the 4th with my Son, and do something.
Then back at it again. I am hoping to approach the locl hospitals with the site on monday.
So. Got to make sure everything is working perfectly with it.

Enjoy.
Carrzkiss
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 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