Bare Metal Disaster Recovery for Windows Vista Home: How to Backup

  1. Create a directory to contain the programs required to perform a backup (e.g. call it Backup).
  2. Copy vshadow.exe and dosdev.exe to that directory.
  3. Create a file called backup.cmd with the following contents:

@REM test if we are called by VSHADOW
if NOT "%CALLBACK_SCRIPT%"=="" goto :IS_CALLBACK

@REM
@REM Get the source and destination path
@REM

set SOURCE_DRIVE_LETTER=%~d1
set SOURCE_RELATIVE_PATH=%~pnx1
set DESTINATION_PATH=%2

@REM
@REM Create the shadow copy - and generate env variables into a temporary script.
@REM
@REM Then, while the shadow is still live
@REM recursively execute the same script.
@REM

@echo ...Determine the scripts to be executed/generated...

set CALLBACK_SCRIPT=%~dpnx0
set TEMP_GENERATED_SCRIPT=%TEMP%\GeneratedVarsTempScript%RANDOM%.cmd

@echo ...Creating the shadow copy...

%~dp0\vshadow.exe -script=%TEMP_GENERATED_SCRIPT% -exec=%CALLBACK_SCRIPT% %SOURCE_DRIVE_LETTER%

del /f %TEMP_GENERATED_SCRIPT%

set CALLBACK_SCRIPT=

@goto :EOF

:IS_CALLBACK
setlocal

@REM
@REM This generated script should set the SHADOW_DEVICE_1 env variable
@REM

@echo ...Obtaining the shadow copy device name...

call %TEMP_GENERATED_SCRIPT%

@REM
@REM This should copy the file to the right location
@REM

@echo ...Copying from the shadow copy to the destination path...
@echo Log file: c:\backup.log

dosdev B: %SHADOW_DEVICE_1%
robocopy /mir /zb /efsraw /copyall /dcopy:t /xj /r:0 /sl /log:c:\backup.log "B:\%SOURCE_RELATIVE_PATH%" %DESTINATION_PATH%
dosdev -r -d B:

Note: this is based on a script from this page: http://blogs.msdn.com/adioltean/archive/2005/01/05/346793.aspx. See that post for a detailed explanation of how the script works.

To run a backup open a Command Prompt as Administrator, i.e.

  1. Click on the Start Menu button
  2. Select All Programs
  3. Select Accessories
  4. Right-click on Command Prompt
  5. Select Run as administrator
  6. Click Continue when prompted

Now change directory to the directory you created in step 1, e.g.

CD C:\Users\Chris\Documents\Backup

Now run the backup command:

backup C:\ E:\backup

Where C:\ is the drive to be backed up and E:\backup is the directory to store the backup.

Leave a Comment