How would I copy the Windows backup folder from an external drive
using command line? I of course want to retain the folder structure,
permissions etc.
You can use the Windows native / built-in Robocopy command line tool with applicable syntax to perform this operation with a batch script. You can also run this with a copy and paste into a command prompt as well not in a batch script.
To run as a batch script though, save the logic to a text document on your desktop, etc. as <something>.cmd
from the text document file | save options. Once saved, just double-click it to execute the logic, and confirm the files have been manipulated as expected afterwards.
SETLOCAL
SET SRC="g:\Something\W7Backup3"
SET ARCH="d:\WindowsImageBackup"
IF NOT EXIST "%ARCH%" MD "%ARCH%"
SET ARCHFName=*.*
SET LOG=G:\ImageBackupCopy.log
:: If you do not want a log file, remove the "/LOG+:%LOG%" below
SET OPT=/S /NP /R:5 /LOG+:%Log% /TS /FP
SET CMD=robocopy %SRC% %ARCH% %ARCHFName% %OPT%
%CMD%
Consider using the below Robocopy syntax where the SET OPT=
options values are different than the above example if you have trouble with the security after the backup is complete.
SETLOCAL
SET SRC="g:\Something\W7Backup3"
SET ARCH="d:\WindowsImageBackup"
IF NOT EXIST "%ARCH%" MD "%ARCH%"
SET ARCHFName=*.*
SET LOG=G:\ImageBackupCopy.log
:: If you do not want a log file, remove the "/LOG+:%LOG%" below
SET OPT=/E /ZB /SEC /COPYALL /SECFIX /R:5 /W:5 /LOG+:%Log% /V
SET CMD=robocopy %SRC% %ARCH% %ARCHFName% %OPT%
%CMD%
Further Resources
If I don't want the log can I also remove the
SET LOG=G:\ImageBackupCopy.log
line? – Raw N – 2016-09-16T00:48:46.960Yes, that is correct, I didn't mention that but if it isn't removed when the
/LOG+:%LOG%
portion is removed, it wouldn't create it or cause any problems.... Sorry about that but you can remove that line as well. – Pimp Juice IT – 2016-09-16T00:50:04.430