Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword or section
Like this
P. 1
Oracle DBA Automation Scripts

Oracle DBA Automation Scripts



|Views: 3,555|Likes:
Published by Shahid Mahmud
Oracle DBA: Backup and Recovery Scripts
By Rajendra Gutta
Oracle DBA: Backup and Recovery Scripts
By Rajendra Gutta

More info:

Published by: Shahid Mahmud on Nov 11, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Oracle DBA: Backup and RecoveryScripts
By Rajendra GuttaHaving the right backup and recovery procedures is crucial to the operation of any database. It is theresponsibility of the database administrator to protect the database from system faults, crashes, and naturalcalamities resulting from a variety of circumstances. Learn how to choose the best backup and recoverymechanism for your Oracle system.Having the right backup and recovery procedures is the lifeblood of any database. Companies live on data,and, if that data is not available, the whole company collapses. As a result, it is the responsibility of thedatabase administrator to protect the database from system faults, crashes, and natural calamities resultingfrom a variety of circumstances.The choice of a backup and recovery mechanism depends mainly on the following factors:
Size of the database
Backup and recovery time
Type of data (OLTP, DSS, Data Warehouse).The types of backup are
Offline backup (Cold or closed database backup)
Online backup (Hot or open database backup)
Logical exportLogical exports create an export file that contains a list of SQL statements to recreate the database. Exportis performed when the database is open and does not affect users work. Offline backups can only beperformed when the database is shut down cleanly, and the database will be unavailable to users while theoffline backup is being performed. Online backups are performed when the database is open, and it doesnot affect users work. The database needs to run in ARCHIVELOG mode to perform online backups.The database can run in either ARCHIVELOG mode or NOARCHIVELOG mode. In ARCHIVELOG mode,the archiver (ARCH) process archives the redo log files to the archive destination directory. These archivefiles can be used to recover the database in the case of a failure. In NOARCHIVELOG mode, the redo logfiles are not archived.When the database is running in ARCHIVELOG mode, the choice can be one or more of the following:
Hot backup
Cold backupWhen the database is running in NOARCHIVELOG mode, the choice of backup is as follows:
Cold backup
Cold Backup
Offline or cold backups are performed when the database is completely shutdown. The disadvantage of anoffline backup is that it cannot be done if the database needs to be run 24/7. Additionally, you can only
recover the database up to the point when the last backup was made unless the database is running inARCHIVELOG mode.The general steps involved in performing a cold backup are shown inFigure 3.1.These general steps are used in writing cold backup scripts for Unix and Windows NT.The steps inFigure 3.1 are explained as follows. Step 1—Generating File ListAn offline backup consists of physically copying the following files:
Data files
Control files
Init.ora and config.ora files
Backing up online redo log files is not advised in all cases, except when performing cold backup with thedatabase running in NOARCHIVELOG mode. If you make a cold backup in ARCHIVELOG mode do notbackup redo log files. There is a chance that you may accidentally overwrite your real online redo logs,preventing you from doing a complete recovery.If your database is running in ARCHIVELOG mode, when you perform cold backup you should also backuparchive logs that exist.Before performing a cold backup, you need to know the location of the files that need to be backed up.Because the database structure changes day to day as more files get added or moved between directories,it is always better to query the database to get the physical structure of database before making a coldbackup.To get the structure of the database, query the following dynamic data dictionary tables:
Lists all the data files used in the database
SQL>select name from v$datafile;
Backup the control file and perform a trace of the control file using
SQL>alter database backup controlfile to '/u10/backup/control.ctl';
SQL>alter database backup controlfile to trace;
Located under 
directoryStep 2—Shut down the databaseYou can shut down a database with the following commands:
$su – oracle$sqlplus "/ as sysdba"SQL>shutdown
Step 3—Perform a backupIn the first step, you generated a list of files to be backed up. To back up the files, you can use the Unixcopy command (cp) to copy it to a backup location, as shown in the following code. You have to copy allfiles that you generated in Step 1.
$cp /u01/oracle/users01.dbf /u10/backup
You can perform the backup of the Init.ora and config.ora files as follows:
$cp $ORACLE_HOME/dbs/init.ora /u10/backup$cp $ORACLE_HOME/dbs/config.ora /u10/backup
Step 4—Start the databaseAfter the backup is complete, you can start the database as follows:
$su – oracle$sqlplus "/ as sysdba"SQL> startup
Hot Backup
An online backup or hot backup is also referred to as ARCHIVE LOG
backup. An online backup can only bedone when the database is running in ARCHIVELOG mode and the database is open. When the databaseis running in ARCHIVELOG mode, the archiver (ARCH) background process will make a copy of the onlineredo log file to archive backup location.An online backup consists of backing up the following files. But, because the database is open whileperforming a backup, you have to follow the procedure shown inFigure 3.2 to backup the files:
Data files of each tablespace
Archived redo log files
Control file
Init.ora and config.ora files

Activity (47)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
kmufasa liked this
irukulapati liked this
Boubacar Keita liked this
Vinay Kumar liked this
Vinay Kumar liked this
Mohammad Zaheer liked this
ankit boxer liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->