0541-0544

Previous Table of Contents Next

Page 541

to make them more sophisticated. For example, you could make the Oracle data dictionary determine which files to backup. Figure 22.7 shows the sample database that scripts try to back up.

Figure 22.7.
Sample Oracle database
layout.


Cold Backup

This cold backup script issues a shutdown immediate command to terminate database operations. It then performs a mass copy of all the database files from the operating system to tape. When it is finished, it restarts the Oracle database instance.

 #!/bin/sh # Oracle RDBMS Cold Backup # shutdown the database $ORACLE_HOME/bin/svrmgrl << EOF connect internal shutdown immediate exit EOF # make copies of all database files, control files, and redo logs find /u*/oradata/norm/*.dbf /u*/oradata/norm/*.ctl /u*/oradata/norm/*.log  cpio -ocvB > /dev/rmt/0hc # startup the database $ORACLE_HOME/bin/svrmgrl << EOF connect internal startup exit EOF 

Page 542

Hot Backup

This hot backup script shows a backup that occurs to disk instead of to tape, as in the cold backup. Whereas the cold backup shuts down the database and does a mass file copy, the hot backup tediously copies the database files for each tablespace. The cold backup is more dynamic than the hot backup because it uses wildcards and the OFA. Whenever a new database file is added or changed, the hot backup must be changed. If it is not changed, an adequate backup has not been taken.

Unlike the cold backup script, which makes its copies to tape, the hot backup script makes copies of the Oracle files to disk. Either type of copy is acceptable for either backup method.

 #!/bin/sh # Oracle Hot Backup Script $ORACLE_HOME/bin/svrmgrl << EOF connect internal REM ** Backup System Tablespace alter tablespace system begin backup; !cp /u01/oradata/norm/system01.dbf /b01/oradata/norm/system01.dbf !cp /u03/oratata/norm/system02.dbf /b03/oradata/norm/system02.dbf alter tablespace system end backup; REM ** Backup TOOLS tablespace alter tablespace tools begin backup; !cp /u01/oradata/norm/tools01.dbf /b01/oradata/norm/tools01.dbf alter tablespace tools end backup; REM ** Backup RBS Tablespace alter tablespace rbs begin backup; !cp /u01/oradata/norm/rbs01.dbf /b01/oradata/norm/rbs01.dbf alter tablespace rbs end backup; REM ** Backup USERS Tablespace alter tablespace users begin backup; !cp /u01/oradata/norm/users01.dbf /b01/oradata/norm/users01.dbf alter tablespace users end backup; REM ** Backup PROD Tablespace alter tablespace prod begin backup; !cp /u03/oradata/norm/prod01.dbf /b03/oradata/norm/prod01.dbf !cp /u05/oradata/norm/prod02.dbf /b03/oradata/norm/prod02.dbf alter tablespace prod end backup; REM ** Perform Control file backup alter database backup controlfile to `/b01/oradata/norm/control.ctl'; alter database backup controlfile to trace; REM ** Backup OnLine Redo Logs !cp /u03/oradata/norm/redo*.log /b03/oradata/norm !cp /u05/oradata/norm/redo*.log /b05/oradata/norm exit EOF 

Page 543

Summary

This chapter discussed the resources available to an Oracle RDBMS to ensure database integrity and consistency. You learned how to implement them in a real-world backup strategy for mission-critical systems.

The information in this chapter barely scratches the surface of the backup and recovery functionality of the Oracle RDBMS. Keep in mind that an Oracle RDBMS is basically a collection of physical database files. Backup and recovery problems are most likely to occur at this level. Three types of files must be backed up: database files, control files, and online redo log files. If you omit any of these files, you have not made a successful backup of the database.

Cold backups shut down the database. Hot backups take backups while the database is functioning. There are also supplemental backup methods , such as exports. Each type of backup has its advantages and disadvantages. The major types of instance recovery are cold restore, full database recovery, time-based recovery, and cancel-based recovery.

This chapter also contains sample scripts that you can use to build your own backup scripts.

Page 544

Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net