set quiet
;
; Check the simulator type
;
if "%SIM_NAME%" == "VAX 11/780" goto CFG78X
if "%SIM_NAME%" == "VAX 8600" goto CFG79X
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo ! You *MUST* use either the VAX-11/78x or VAX 86x0 simulators to run  !
echo ! this particular turnkey kit.  Either the simulator you have used is !
echo ! incorrect, or there is a serious error condition in the simulator.  !
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
goto END
;
; Detected simulator: SIMH VAX-11/78x
;
:CFG78X
set ENV CNSL_MEDIA=rx01/AS-T213P-ME.rx1
set ENV CNSL_SIMH=CS0

set ENV TAPE_SIMH=TU0

set ENV BOOT_VMS4=DRA0
set ENV SHR0_VMS4=DRA1
set ENV SHR1_VMS4=DRA2
set ENV SHR2_VMS4=DRA3
set ENV SPL0_VMS4=DUA0
set ENV SPL1_VMS4=DUA1
set ENV HOM0_VMS4=DRA4
set ENV HOM1_VMS4=DRA5
set ENV TAPE_VMS4=MTA0

set ENV PFX=780
goto CFGDN
;
; Detected simulator: SIMH VAX-11/79x (VAX 86x0)
;
:CFG79X
set ENV CNSL_MEDIA=rl02/BC-FI18T-DE.rl2
set ENV CNSL_SIMH=CS0

set ENV TAPE_SIMH=TS0

set ENV BOOT_VMS4=DUA0
set ENV SHR0_VMS4=DUA1
set ENV SHR1_VMS4=DUA2
set ENV SHR2_VMS4=DUA3
set ENV SPL0_VMS4=DUB0
set ENV SPL1_VMS4=DUB1
set ENV HOM0_VMS4=DRA0
set ENV HOM1_VMS4=DRA1
set ENV TAPE_VMS4=MSA0

set ENV PFX=795
goto CFGDN
:CFGDN
set ENV BAK_DIR=bak/backups/%DATE_YY%%DATE_MM%%DATE_DD%
if not exist bak/backups mkdir bak/backups
if not exist %BAK_DIR% mkdir %BAK_DIR%
set CONSOLE LOG=%BAK_DIR%/backup%PFX%.log
echo ************************************************************************
echo *        BACKUP STARTED AT %TIME%                                    *
echo ************************************************************************
noexpect
set %TAPE_SIMH% WRITE
attach %CNSL_SIMH% -e dist/media/%CNSL_MEDIA%
expect "PLEASE ENTER DATE AND TIME (DD-MMM-YYYY  HH:MM)  " send "%DATE_DD%-%DATE_MMM%-%DATE_19XX_YYYY% %TIME%"; continue
if "%SIM_NAME%" == "VAX 11/780" goto BAK78X
if "%SIM_NAME%" == "VAX 8600" goto BAK79X
:BAK78X

goto BAKRUN
:BAK79X
expect "Insert the first standalone system volume and enter \"YES\" when ready: " attach %CNSL_SIMH% -e bak/staba047.rl2 ; send -t after=250k "yes\r"; continue
goto BAKRUN
:BAKRUN
expect "$ " attach %TAPE_SIMH% %BAK_DIR%/vms047_%PFX%.tap ; send -t after=60m "backup/image/verify %BOOT_VMS4%: %TAPE_VMS4%:system.bck/rewind/label=SYSBAK\r"; continue
expect "Enter \"YES\" to continue: " send "yes\r"; continue
expect "$ " attach %TAPE_SIMH% %BAK_DIR%/share0_%PFX%.tap ; send -t after=60m "backup/image/verify %SHR0_VMS4%: %TAPE_VMS4%:share0.bck/rewind/label=SH0BAK\r"; continue
expect "Enter \"YES\" to continue: " send "yes\r"; continue
expect "$ " attach %TAPE_SIMH% %BAK_DIR%/share1_%PFX%.tap ; send -t after=60m "backup/image/verify %SHR1_VMS4%: %TAPE_VMS4%:share1.bck/rewind/label=SH1BAK\r"; continue
expect "Enter \"YES\" to continue: " send "yes\r"; continue
expect "$ " attach %TAPE_SIMH% %BAK_DIR%/share2_%PFX%.tap ; send -t after=60m "backup/image/verify %SHR2_VMS4%: %TAPE_VMS4%:share2.bck/rewind/label=SH2BAK\r"; continue
expect "Enter \"YES\" to continue: " send "yes\r"; continue
expect "$ " attach %TAPE_SIMH% %BAK_DIR%/spool_%PFX%.tap ; send -t after=60m "backup/image/verify %SPL0_VMS4%:,%SPL1_VMS4%: %TAPE_VMS4%:spool.bck/rewind/label=SPLBAK\r"; continue
expect "Enter \"YES\" to continue: " send "yes\r"; continue
expect "$ " attach %TAPE_SIMH% %BAK_DIR%/home_%PFX%.tap ; send -t after=60m "backup/image/verify %HOM0_VMS4%:,%HOM1_VMS4%: %TAPE_VMS4%:home.bck/rewind/label=HOMBAK\r"; continue
expect "Enter \"YES\" to continue: " detach %TAPE_SIMH%; detach %CNSL_SIMH%; attach %CNSL_SIMH% -e dist/media/%CNSL_MEDIA%; goto STOP
boot %CNSL_SIMH%
:EOS
continue
:STOP
echo  
echo ************************************************************************
echo *        BACKUP ENDED AT %TIME%                                      *
echo ************************************************************************
set CONSOLE NOLOG
:END
