Scheduling Tape Backups

This document describes the considerations for setting up a system in which tape backups are executed automatically, and includes an example of how to do it.

You need to consider whether the system is rebooted each day, or runs continuously. Even if it runs continuously, you must include a method for the rescheduling of a task aborted by a shutdown. The example that follows is based on a system that runs continuously and reboots are permitted except for the time between midnight and 1:55 am. It uses the CCIBOOT.BAT file to invoke JOBMGR and to schedule another file, CCIBACK.BAT, that checks for the day of the week and schedules the file BACKUP.BAT for execution on the following day at 1:55 am. BACKUP.BAT is the batch file that calls ALL.BAT, which batch file that actually runs the backups of each drive using the FBACKUP.EXE program. BACKUP.BAT also makes an error log by sending the screen image of the console doing the backup to a file with TERMSET.

CCIBOOT.BAT
@echo off
echo Doing %0 using params %1 %2 %3 %4
if "%USER%"==""     set USER=%1
if "%STATION%"==""  set STATION=%2
if "%WINDOW%"==""   set WINDOW=%3
path c:\cdos;f:\tools;c:\batches
set cspool=%bootdrv%\cdos\spool
REM NEXT TWO VARIABLES DETERMINE CONSOLE USED FOR BACKUP:
SET BU=71
SET FS=72
rem  set two environmental variables for backup and fileserver
cdspl boot
espl boot
cspool boot
lookout
&setcci
prompt (User %USER%-$u) $p$g
e:
d:
force %FS% cd i:=e:\mc
force %FS% i:
force %FS% cd \
force %FS% fserve
rem starting our fileserver on user 72, a phantom console
c:
jobmgr era \postoffc\*.MLK >nul
force %BU% SET BU=%BU%
schedule cls on %BU% wait 1 retries 5 now+ 5
schedule cciback.bat on %BU% wait 1 retries 5 now+ 10

CCIBACK.BAT

@echo off
rem  This batch file is called by cciboot when the system
rem  is rebooted.
rem  It schedules other batch files, which call this one
rem  when they are finished.
rem  This method keeps the clutter out of cciboot.
rem
@echo %0 is running
@echo 0
date /b/e
if "%DOW%"=="MON" goto mon_back
if "%DOW%"=="TUE" goto tue_back
if "%DOW%"=="WED" goto wed_back
if "%DOW%"=="THU" goto thu_back
if "%DOW%"=="FRI" goto fri_back
if "%DOW%"=="SAT" goto sat_back
if "%DOW%"=="SUN" goto sun_back
exit
:mon_back
schedule cls on %BU% wait 1 retries 5 TUES 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 TUES 0200 >nul
exit
:tue_back
schedule cls on %BU% wait 1 retries 5 WED 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 WED 0200 >nul
exit
:wed_back
schedule cls on %BU% wait 1 retries 5 THURS 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 THURS 0200 >nul
exit
:thu_back
schedule cls on %BU% wait 1 retries 5 FRI 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 FRI 0200 >nul
exit
:fri_back
schedule cls on %BU% wait 1 retries 5 SAT 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 SAT 0200 >nul
exit
:sat_back
schedule cls on %BU% wait 1 retries 5 SUN 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 SUN 0200 >nul
exit
:sun_back schedule cls on %BU% wait 1 retries 5 MON 0155 >nul
schedule backup.bat on %BU% wait 1 retries 5 MON 0200 >nul
exit

BACKUP.BAT

@echo off
rem This batch file does the real work: it calls the tape
rem batch file on most days, produces audit files,
rem stops/starts the spooler, and other jobs as needed.
rem A common exit point is used.
rem
@echo %0 is running now
date /b/e
printer 14
cspool quit
xdel c:\*.bak /s/n
if "%DOW%"=="MON" goto mon_back
if "%DOW%"=="TUE" goto tue_back
if "%DOW%"=="WED" goto wed_back
if "%DOW%"=="THU" goto thu_back
if "%DOW%"=="FRI" goto fri_back
if "%DOW%"=="SAT" goto sat_back
if "%DOW%"=="SUN" goto sun_back
EXIT
:mon_back
@echo          Monday
f:
cd \safe
goto all_done
:tue_back
@echo          Tuesday
f:
cd \safe
call all.bat
termset u%BU% print file=stat%DOW%
goto all_done
:wed_back
@echo          Wednesday
f:
cd \safe
call all.bat
termset u%BU% print file=stat%DOW%
goto all_done
:thu_back
@echo          Thursday
f:
cd \safe
call all.bat termset u%BU% print file=stat%DOW%
goto all_done
:fri_back
@echo          Friday
f:
cd \safe
call all.bat
termset u%BU% print file=stat%DOW%
goto all_done
:sat_back
@echo          Saturday
f:
cd \safe
call all.bat
termset u%BU% print file=stat%DOW%
goto all_done
:sun_back
@echo          Sunday
c:
cd %security%
ren history.dat history.%DOY%
attrib history.%DOY% +a
cd \
f:
rem  General exit point
:all_done
cspool start
cciback
exit


ALL.BAT

memsize 300
@echo doing c
FBACKUP /QE /CT /TN1 /DN1 C:\*.*/S/Y/H/R/I/D:1-1-80/B:12-31-2107
@echo     results %ERRORLVL%
@echo doing e
FBACKUP /QE /CT /TN1 /DN2 E:\*.*/S/Y/H/R/I/D:1-1-80/B:12-31-2107
@echo     results %ERRORLVL%
@echo doing d
FBACKUP /QE /CT /TN1 /DN3 D:\*.*/S/Y/H/R/I/D:1-1-80/B:12-31-2107
@echo     results %ERRORLVL%
memsize 640

The status log that is created looks like this:

        Tuesday
doing c 
results 000
doing e
results 000
doing d
results 000

The "results 000" line refers to the errorlevel returned by the
tape backup software;  if a problem had occurred, the errorlevel
environmental variable would be set to greater than 000.