Backup Computer to VHD

@Echo off

REM A simple backup system using disk2vhd
REM requires ‘disk2vhd.exe’ to be in the path

setLocal EnableDelayedExpansion

REM “DRIVES” can be one drive identifier with colon, multiple separated by spaces,
REM or asterisk for all.
REM “DEST” can be a drive letter or a UNC.

SET DRIVES=”*”
SET DEST=”\\SERVER\SHARE”

REM Keep most recent 4 VHD files in DEST, delete the rest
for /f “skip=4 tokens=* delims= ” %%a in (‘dir/b/o-d %DEST%\*.VHD’) do (
del %DEST%\%%a
)

REM Backup to VHD
C:
cd \
DISK2VHD %DRIVES% %DEST%\D2VBK–%date:~-10,2%%date:~-7,2%%date:~-4,4%_TS.VHD

email me