@echo ***** FIRST-OF-THE-MONTH BACKUP PROGRAM *********************************
@echo off
if not "%1" == "" goto start
@echo ##### Usage:   BU_MONTH  tape_label  ######
goto end
rem ***** test for aspi manager, load it if not present ***********************
:start
loadaspi -q -s
if errorlevel 10 if not errorlevel 12 goto loadfe
loadaspi -q c:\bin\aspi2dos.sys
if not errorlevel 1  goto loadfe
@echo ##### LOADASPI failed to install the ASPI Manager #####
goto fatal
rem ***** test for datman file engine, load it if not present *****************
:loadfe
datmanfe -q -s
if errorlevel 12 if not errorlevel 13 goto format
datmanfe -q -x2048 -nMY_STATION -vh -p0
if not errorlevel 1 goto format
if errorlevel 24 if not errorlevel 25 @echo ##### No DAT (or No Power) #####
@echo ##### DATMANFE failed to install the File Engine #####
goto fatal
rem ***** start extended format operation *************************************
:format
datman -y dformatx "%1" "Tape of the Month Backup. %1"
if not errorlevel 1 goto sleep
@echo ##### DFORMATX failed. #####
goto fatal
rem ***** enter idle mode *****************************************************
:sleep
wakeup  1:00am
if not errorlevel 1 goto timeup
@echo Do you wish to end the Monthly Backup batch program? (Ctrl-Break to end)
pause
rem ***** unload/reload aspi manager to reset the tape drive ******************
:timeup
datman dreset
datman dmount
datman -q dstatus
if not errorlevel 1 goto backup
@echo ##### Tape Not Ready for Backup Operation #####
goto fatal
rem ***** full backup operation starts here ***********************************
:backup
dcopy c:\ t:\drive_c    /h/i/c/e/y/j0/x~*.tmp/xwin386.swp/oc:\bumonthc.log
dcopy f:\ t:\drive_f /hb/h/i/c/e/y/j0/x~*.tmp            /oc:\bumonthf.log
dflush
datmanfe -q -u
loadaspi -q -u
dir c:\bumonth?.log
@echo !!!!! First-of-the-Month (%1) backup complete !!!!!
goto end
rem ***** fatal case **********************************************************
:fatal
datmanfe -q -u
loadaspi -q -u
@echo ##### Fatal error, batch file terminated. #####
goto end
:end
wakeup never
