run robocopy bat to copy entire drive to another drive
Solution 1
with "D:"
you are not specifying the root directory of the D drive (D:\
) but the current directory of D instead, (D:\temp
in your example).
To solve this problem, just add \
to the source spec (and while there, to the dest spec as well)
robocopy d:\ k:\ /L /v
Solution 2
Use the /E
Option.
Also check other necessary/useful params like /copyall
/ZB
or /DCOPY:DAT
via /?
.
Solution 3
/L options make a dry run, nothing actually copied.
From MS website: /l Specifies that files are to be listed only (and not copied, deleted, or time stamped).
here is sample of my test dry run before copying and entire disk:
Total Copied Skipped Mismatch FAILED Extras Dirs : 63346 63346 2 0 0 0 Files : 719564 719564 0 0 0 0 Bytes : 4.039 t 4.039 t 0 0 0 0 Times : 0:27:58 0:00:00 0:00:00 0:27:57 Ended : Monday, September 6, 2021 9:25:35 AM
and here is my Notepad for making my command, (notice I simply remove the /L to actually copy):
for testing (dry run): robocopy Q: G: /L /E /COPYALL /R:20 /W:15 /MT /NP /A-:SH /Z /V /TEE /LOG+:VMRobCp.log
Real run: robocopy Q: G: /E /COPYALL /R:20 /W:15 /MT /NP /A-:SH /Z /V /TEE /LOG+:VMRobCp.log
cherrytree
Updated on July 25, 2022Comments
-
cherrytree almost 2 years
I'm trying to run a simple backup (mirror) of one entire drive (d:) to another drive (k:). I've created a .bat file ('backup.bat') defining the source (d:) and destination (k:) and placed this batch file within a folder on the d drive (d:\temp). When I double-click on the batch file it defines the source as d:\temp, instead of what I've defined it as in the batch file; d:.
Here is the text in the .bat file:
@echo off echo To begin backing up data: pause robocopy "D:" "K:" /L /v echo. pause exit
And this is what shows up when I double-click on the backup.bat
As you can see, source is defined as d:\temp. This is where the batch file is located, but in the batch file I defined it as D:. For some reason, the destination is defined correctly.
Any ideas?
-al
EDIT: If I add the '/' to the source and destination location, see code below, I see even more odd behavior (see screenshot). The source is now both the defined source and destination combined, w/ no destination.
@echo off echo To begin backing up data: pause robocopy "D:\" "K:\" /L /v echo. pause exit
And, if I remove the "" from the source and destination....IT WORKs!
@echo off echo To begin backing up data: pause robocopy D:\ K:\ /L /v echo. pause exit
-
cherrytree about 10 yearsI've tried that and it produces something even more odd. See my edits above.
-
cherrytree about 10 years@ PA. was correct, I not only needed to add the \, I also needed to remove the quotes. Thanks for the help.
-
thenobes almost 4 yearsFwiw, I recalled the reason for using a space following an ending slash, when within a quote. It seems that if you leave out the space, robocopy doesn’t see that there is a path that ends in a slash, and so assumes that you entered a file name.
-
Patrick Burwell over 2 yearsWhy not just use the /MIR?