Dynamic Hot Backups
Sample Code # 1



$! CE ~ Change Environment: Points to instance AA of the PRD database.
$ CE PRDAA
$ ON ERROR THEN GOTO ERROR_HANDLER
$! If the tape drive is not specified, default to $2$MUA1.
$ IF P1 .eqs. "" THEN P1 = "$2$MUA1"
$ TD = P1
$! The DUP symbol simplifies invoking the BACKUP command.
$ DUP = "BACKUP/IGNORE=(INTERLOCK,NOBACKUP,LABEL)/LOG"
$! Initialize the tape, naming it ORAINC.
$ INIT/DENS=6250 'TD' ORAINC
$! Write a timestamp to the file.
$ SHOW TIME
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Put the SCRATCH tablespace into backup mode.
ALTER TABLESPACE SCRATCH BEGIN BACKUP;
REM Exit from SQL*DBA.
EXIT;
$! Back up all of the data files for the tablespace.
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_SCRATCH.TBS 'TD':PROD_FID_004.BCK/SAV
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_SCRATCH2.TBS 'TD':PROD_FID_006.BCK/SAV
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Take the SCRATCH tablespace out of backup mode.
ALTER TABLESPACE SCRATCH END BACKUP;
REM Put the MEMBERSHIP tablespace into backup mode.
ALTER TABLESPACE MEMBERSHIP BEGIN BACKUP;
REM Exit from SQL*DBA.
EXIT;
$! Back up all of the data files for the tablespace.
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_MEMBERSHIP.TBS 'TD':PROD_FID_005.BCK/SAV
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Take the MEMBERSHIP tablespace out of backup mode.
ALTER TABLESPACE MEMBERSHIP END BACKUP;
REM Put the SYSTEM tablespace into backup mode.
ALTER TABLESPACE SYSTEM BEGIN BACKUP;
REM Exit from SQL*DBA.
EXIT;
$! Back up all of the data files for the tablespace.
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_SYSTEM.DBS 'TD':PROD_FID_001.BCK/SAV
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Take the SYSTEM tablespace out of backup mode.
ALTER TABLESPACE SYSTEM END BACKUP;
REM Put the ROLLBACKS tablespace into backup mode.
ALTER TABLESPACE ROLLBACKS BEGIN BACKUP;
REM Exit from SQL*DBA.
EXIT;
$! Back up all of the data files for the tablespace.
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_ROLLBACKS.TBS 'TD':PROD_FID_002.BCK/SAV
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Take the ROLLBACKS tablespace out of backup mode.
ALTER TABLESPACE ROLLBACKS END BACKUP;
REM Put the TEMP tablespace into backup mode.
ALTER TABLESPACE TEMP BEGIN BACKUP;
REM Exit from SQL*DBA.
EXIT;
$! Back up all of the data files for the tablespace.
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_TEMP.TBS 'TD':PROD_FID_003.BCK/SAV
$ DUP DISK$USER:[ORACLE.ORACLEV6A.DB_IOUG]ORA_TEMP2.TBS 'TD':PROD_FID_007.BCK/SAV
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Take the TEMP tablespace out of backup mode.
ALTER TABLESPACE TEMP END BACKUP;
REM Initiate a log switch.
ALTER SYSTEM SWITCH LOGFILE;
REM Exit from SQL*DBA.
EXIT;
$! Wait 10 minutes for the archiver to finish moving the redo log.
$ WAIT 00:10
$! There should be at least ONE archive log!
$ IF F$SEARCH("ORA_ARCHIVE:*.ARC")
$ THEN
$! By renaming them, we avoid the possibility of an additional log
$! file being created while we are backing up the existing ones
$! and getting deleted along with the ones that were backed up.
$    RENAME/LOG ORA_ARCHIVE:*.ARC *.ARCLOGS
$    DUP ORA_ARCHIVE:*.ARCLOGS 'TD':ARCLOGS.BCK/SAV
$!   DELETE/LOG ORA_ARCHIVE:*.ARCLOGS;
$ ENDIF
$! Enter SQL*DBA
$ SQLDBA LMODE=Y
CONNECT INTERNAL;
REM Back up a copy of the control file.
ALTER DATABASE BACKUP CONTROLFILE TO 'SYSUTIL$COM:CONTROL.BKP' REUSE;
REM Exit from SQL*DBA.
EXIT;
$! Move the backup control file to tape.
$ DUP SYSUTIL$COM:CONTROL.BKP 'TD':CONTROL.BCK/SAV
$! Write another timestamp to the file.
$ SHOW TIME
$ GOTO FINISH_TAPE
$ ERROR_HANDLER:
$! If an error occurred, page OPER/DBA with relevant info.
$ RAMPAGE OPERATOR,REAGAN "HOT BACKUP FAILED.  PLEASE RESPOND ASAP."
$ FINISH_TAPE:
$ EXIT


Return to the Dynamic Hot Backups article.


Volume III Issue 1 Table of Contents


File maintained by Matt Reagan; last modified 10-FEB-1996.