Call (800) 766-1884 for Oracle support & training
Free Oracle Tips


Oracle Consulting Support
Oracle Upgrades
Use New Oracle Features
Oracle Replication Support
Oracle Training
Remote Oracle DBA
System Documentation
Oracle Tips
Oracle Performance
 

Free Oracle Tips


 

HTML Text

BC Oracle tuning

Oracle training

Oracle support

Remote Oracle

 

 

   
 

Backup and Restoration


Oracle Tips by Burleson
 

Of all the tasks accomplished with scripts in an Oracle database, the automation of system backups (and to a lesser extent recovery of a database) is probably the most important. Most Oracle installations (especially those IS shops that use hot backups) automate the process of performing system backups.

Listing 1.1 is a generic script for a cold backup of an Oracle database. The OS-level commands that perform the backup of files have been excluded.

Listing 1.1 A generic cold backup script for an Oracle database.

 #
 # Set up the environment variables.
 #
 ORACLE_SID=registrar_db; export ORACLE_SID
 ORACLE_HOME=/dbhost/database/oracle/v722; export ORACLE_HOME

 #
 # Shutdown the database.
 #
 svrmgrl
 connect internal
 shutdown immediate

 #
 # Backup the database control files, redo logs, and dbf files.
 #
 <OS commands to backup files here>

 #
 # Restart the database.
 #
 svrmgrl
 connect internal
 startup

Listing 1.2 is a generic script for a hot backup of an Oracle database. Again, the OS-level commands that perform the backup of files have been excluded.

Listing 1.2 A generic hot backup script for an Oracle database.

 #
 # Set up the Oracle environment variables.
 #
 ORACLE_SID=registrar_db; export ORACLE_SID
 ORACLE_HOME=/dbhost/database/oracle/v722; export ORACLE_HOME

 #
 # Shut down the database.
 #
 svrmgrl lmode=Y
 connect internal

 #
 # Back up each tablespace individually.
 #
 alter tablespace SYSTEM begin backup;
 <OS command to backup the.dbf files containing the SYSTEM tablespace>
 alter tablespace SYSTEM end backup;

 alter tablespace ROLLBACK begin backup;
 <OS command to backup the .dbf files containing the rollback tablespace>
 alter tablespace ROLLBACK end backup;

 alter tablespace APPLICATION begin backup;
 <OS command to backup the .dbf files containing the application tablespace>
 alter tablespace APPLICATION end backup;

 alter tablespace INDEXES begin backup;
 <OS command to backup the .dbf files containing the application tablespace>
 alter tablespace INDEXES end backup;

 #
 # Turn off archive log and back up the archive log files.
 #
 archive log stop
 exit

 #
 # Store a list of existing archive log files for export.
 #
 <OS command to generate a list of files>
 svrmgrl lmode=y
 connect internal
 archive log start
 exit

 #
 # Make sure the archive log files also get backed up.
 #
 <OS command to backup the archive log files>
 <OS command to remove the archive log files that were backed up>

 #
 # Make a copy of the controlfile to be backed up.
 #
 svrmgrl lmode=y
 alter database backup controlfile to <path for controlfile backup>
 exit
 <OS command to backup the controlfile copy>

This is an excerpt from the book "High Performance Oracle Database Automation" by Jonathan Ingram and Donald K. Burleson, Series Editor.

  
 

Oracle performance tuning software 
 
 
 
 

Oracle performance tuning book

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

   

Copyright © 1996 -  2014 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation. 

Hit Counter