I'm using such simple backup script using Disk2VHD. I would like to change it a little bit so it would check the C disk drive usage and compare it with F drive, so old images would be only removed if there is not enough free disk space on F.
Currently it removes old images when more than 4 is already created.
REM
REM A simple backup system using disk2vhd
REM
REM version 1.3, by J.E.B., 2011-02-22
REM
REM requires 'disk2vhd.exe' to be in the path
REM
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="C:"
SET DEST="F:"
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%\%COMPUTERNAME%--%date:~-10,3%%date:~-7,2%%date:~-4,4%.VHD
EXIT /B n