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
robocopy C:\src D:\dst /E /COPYALL This syntax will copy all NTFS ACLs, file owners, subfolders (including empty folders) and all file attributes from one drive to another. C:\src refers to the source drive, D:\src is the target drive, /E selects to include all empty subfolders and /COPYALL to catch the rest.
Copy examples The easiest way to copy a folder with all files and subfolders is to run this command: robocopy c:\temp\source c:\temp\destination /E /DCOPY:DAT /R:10 /W:3. The /E switch tells Robocopy to copy all subfolders, including empty ones. If you don't want to copy empty subfolders, use the /S switch.
Robocopy with Scheduled Tasks. You can create a scheduled task to automatically run your robocopy script at a specified time.
Excludes existing files with the same timestamp, but different file sizes. Source directory files newer than the destination are excluded from the copy. Source directory files older than the destination are excluded from the copy.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With