begin-report
do STARTUP
do GET_TABLESPACES
do SHUTDOWN
end-report
begin-procedure STARTUP
open 'SYSUTIL$COM:HOT_BACKUP.COM' as 1 for-writing record=256
write 1 from
'$! CE ~ Change Environment: Points to instance AA of the PRD database.'
write 1 from '$ CE PRDAA'
write 1 from '$ ON ERROR THEN GOTO ERROR_HANDLER'
write 1 from '$! If the tape drive is not specified, default to $2$MUA1.'
write 1 from '$ IF P1 .eqs. "" THEN P1 = "$2$MUA1"'
write 1 from '$ TD = P1'
write 1 from '$! The DUP symbol simplifies invoking the BACKUP command.'
write 1 from '$ DUP = "BACKUP/IGNORE=(INTERLOCK,NOBACKUP,LABEL)/LOG"'
write 1 from '$! Initialize the tape, naming it ORAINC.'
write 1 from '$ INIT/DENS=6250 ''TD'' ORAINC'
write 1 from '$! Write a timestamp to the file.'
write 1 from '$ SHOW TIME'
write 1 from '$! Enter SQL*DBA'
write 1 from '$ SQLDBA LMODE=Y'
write 1 from 'CONNECT INTERNAL;'
end-procedure ! STARTUP
begin-procedure GET_TABLESPACES
begin-select
TABLESPACE_NAME
SUM(BYTES) &SUM_BYTES
do GET_DATA_FILES
from DBA_DATA_FILES
group by TABLESPACE_NAME
order by SUM(BYTES) DESC
end-select
end-procedure ! GET_TABLESPACES
begin-procedure GET_DATA_FILES
write 1 from 'REM Put the SCRATCH tablespace into backup mode.'
write 1 from 'ALTER TABLESPACE ' &TABLESPACE_NAME ' BEGIN BACKUP;'
write 1 from REM Exit from SQL*DBA.'
write 1 from 'EXIT;'
write 1 from '$! Back up all of the data files for the tablespace.'
begin-select
FILE_NAME
FILE_ID
move &FILE_ID to $FILE_ID 000
write 1 from '$ DUP ' &FILE_NAME ' ''TD'':PROD_FID_' $FILE_ID '.BCK/SAV'
from DBA_DATA_FILES
where TABLESPACE_NAME = &TABLESPACE_NAME
end-select
write 1 from '$! Enter SQL*DBA'
write 1 from '$ SQLDBA LMODE=Y'
write 1 from 'CONNECT INTERNAL;'
write 1 from 'REM Take the SCRATCH tablespace out of backup mode.'
write 1 from 'ALTER TABLESPACE ' &TABLESPACE_NAME ' END BACKUP;'
end-procedure ! GET_DATA_FILES
begin-procedure SHUTDOWN
write 1 from 'REM Initiate a log switch.'
write 1 from 'ALTER SYSTEM SWITCH LOGFILE;'
write 1 from 'REM Exit from SQL*DBA.'
write 1 from 'EXIT;'
write 1 from
'$! Wait 10 minutes for the archiver to finish moving the redo log.'
write 1 from '$ WAIT 00:10'
write 1 from '$! There should be at least ONE archive log!'
write 1 from '$ IF F$SEARCH("ORA_ARCHIVE:*.ARC")'
write 1 from '$ THEN'
write 1 from
'$! By renaming them, we avoid the possibility of an additional log'
write 1 from
'$! file being created while we are backing up the existing ones'
write 1 from
'$! and getting deleted along with the ones that were backed up.'
write 1 from '$ RENAME/LOG ORA_ARCHIVE:*.ARC *.ARCLOGS'
write 1 from '$ DUP ORA_ARCHIVE:*.ARCLOGS ''TD'':ARCLOGS.BCK/SAV'
write 1 from '$!! DELETE/LOG ORA_ARCHIVE:*.ARCLOGS;'
write 1 from '$ ENDIF'
write 1 from '$! Enter SQL*DBA'
write 1 from '$ SQLDBA LMODE=Y'
write 1 from 'CONNECT INTERNAL;'
write 1 from 'REM Back up a copy of the control file.'
write 1 from
'ALTER DATABASE BACKUP CONTROLFILE TO ''SYSUTIL$COM:CONTROL.BKP'' REUSE;'
write 1 from 'REM Exit from SQL*DBA.'
write 1 from 'EXIT;'
write 1 from '$! Move the backup control file to tape.'
write 1 from '$ DUP SYSUTIL$COM:CONTROL.BKP ''TD'':CONTROL.BCK/SAV'
write 1 from '$! Write another timestamp to the file.'
write 1 from '$ SHOW TIME'
write 1 from '$ GOTO FINISH_TAPE'
write 1 from '$ ERROR_HANDLER:'
write 1 from '$! If an error occurred, page OPER/DBA with relevant info.'
write 1 from
'$ RAMPAGE OPERATOR,REAGAN "HOT BACKUP FAILED. PLEASE RESPOND ASAP."'
write 1 from '$ FINISH_TAPE:'
write 1 from '$ EXIT'
close 1
end-procedure ! SHUTDOWN
Return to the Dynamic Hot Backups article.
Volume III Issue 1 Table of Contents