[Project: Mind Map]
Plan
Overview
Step 1
Create working area
Thumb drive for projects and backup files
Step 2
Transform working area to working location
DAS or NAS for permantent storage
Backup of item 1.
Documentation for emergency recovery
...
Sub-Project
Flash drive backup script with DD.exe
MakeBackupOfFlashDrive.cmd@echo off && TITLE %~nx0 && setlocal
for /f "tokens=*" %%i in ('cd') do set _currentpath=%%i
echo ********************************************************
echo * IMPORANT! - Please remove USB drive before this test *
echo ********************************************************
pause
for /f "tokens=*" %%i in ('wmic logicaldisk get volumename') do set _volnametmp=%%i
dd --list 2> pre-dd-list.log
echo *** pre-dd-list.log ***
type pre-dd-list.log
echo *** NOW insert the USB drive device ***
pause
for /f "tokens=*" %%i in ('wmic logicaldisk get volumename') do set _volname=%%i
echo "%_volnametmp%"
echo "%_volname%"
if "%_volnametmp%" == "%_volname%" set _volname=dummyname
dd --list 2> post-dd-list.log
echo *** post-dd-list.log ***
type post-dd-list.log
echo.
echo *** identify new flash drive ***
echo.
fc pre-dd-list.log post-dd-list.log
echo --- filter new device ----------------
fc /L pre-flash.log post-flash.log | find "\\?\Device\" | find "\Partition0"
echo --------------------------------------
for /f "tokens=*" %%i in ('fc /L pre-flash.log post-flash.log ^| find "\\?\Device\" ^| find "\Partition0"') do set _if=%%i
set _of=%_volname%
echo ----------------------------
echo USB Device: %_if%
echo USB Volname: %_volname%
echo Output Name: %_of%
echo ----------------------------
echo Should I create disk to file image?
echo dd bs=256M if=%_if% of=%_currentpath%\%_of%.dd --progress
echo ============================
:prompt
set /p yn=Yes or No (y/n)
if /i "%yn%" equ "y" GOTO :d2f
if /i "%yn%" equ "n" GOTO :d2d
goto :prompt
:d2f
echo = Disk to File IMAGE =
pause
echo ...writing...
echo on
dd bs=256M if=%_if% of=%_currentpath%\%_of%.dd --progress
@echo off
echo.
echo .DONE DISK TO FILE IMAGE
goto :end
:d2d
echo ...creating new empty vhd(x)...
echo list disk >diskpart.txt
echo create vdisk file=%_currentpath%\%_of%.vhd maximum=16000 type=expandable >>diskpart.txt
echo select vdisk file=%_currentpath%\%_of%.vhd >>diskpart.txt
echo attach vdisk >>diskpart.txt
echo list disk >>diskpart.txt
echo convert mbr >>diskpart.txt
echo exit >>diskpart.txt
diskpart /s diskpart.txt
wmic logicaldisk get blocksize, volumename, description, deviceid, drivetype, filesystem, mediatype, name, numberofblocks, size, status, statusinfo
dd --list 2> post2-dd-list.log
echo *** post2-dd-list.log ***
type post2-dd-list.log
echo.
echo *** identify new vdisk ***
echo.
fc post-dd-list.log post2-dd-list.log
echo --- filter new device ----------------
fc /L post-dd-list.log post2-dd-list.log | find "\\?\Device\" | find "\Partition0"
echo --------------------------------------
for /f "tokens=*" %%i in ('fc /L post-dd-list.log post2-dd-list.log ^| find "\\?\Device\" ^| find "\Partition0"') do set _of=%%i
echo ----------------------------
echo USB Device: %_if%
echo USB Volname: %_volname%
echo Output Name: %_of%
echo ----------------------------
echo Should I create disk to disk image?
echo dd bs=256M if=%_if% of=%_of% --progress
echo ============================
:prompt2
set /p yn=Yes or No (y/n)
if /i "%yn%" equ "y" GOTO :ok
if /i "%yn%" equ "n" GOTO :end
goto :prompt2
:ok
echo = Disk to Disk IMAGE =
pause
echo ...writing...
echo on
dd bs=256M if=%_if% of=%_of% --progress
@echo off
echo.
echo .DONE DISK TO DISK IMAGE
goto :end
:end
endlocal