1

I often restore Windows 7 system from a WindowsImageBackup folder from drive d: using a Windows installation disk. I also keep incremental backups on external HDD. Provided that I formatted d: how would I copy the Windows backup folder from an external drive ex. g:\Something\W7Backup3 to d:\WindowsImageBackup using command line? I off course want to retain the folder structure, permissions etc.

1

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 Sep 16 '16 at 0:48
  • Yes, 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 Sep 16 '16 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.