Solved

Robocopy - correct switches to use

Posted on 2009-06-30
9
680 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
  • 6
  • 3
9 Comments
 
LVL 30

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 30

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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 30

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 30

Accepted Solution

by:
Wayne Barron earned 500 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 30

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 30

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

860 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