Copying WindowsImageBackup in command line
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.
Solution 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
- Robocopy