diff --git a/3677.pdf b/3677.pdf new file mode 100644 index 0000000..9ec3bc3 Binary files /dev/null and b/3677.pdf differ diff --git a/3678.pdf b/3678.pdf new file mode 100644 index 0000000..ea63dd0 Binary files /dev/null and b/3678.pdf differ diff --git a/9781590598511.jpg b/9781590598511.jpg new file mode 100644 index 0000000..39a7352 Binary files /dev/null and b/9781590598511.jpg differ diff --git a/Chapter09/r_9_1.txt b/Chapter09/r_9_1.txt new file mode 100644 index 0000000..8fe37a7 --- /dev/null +++ b/Chapter09/r_9_1.txt @@ -0,0 +1,102 @@ +# Beginning of Script +# Start of Configurable Section +export ORACLE_HOME=/opt/oracle/10.2/db_1 +export ORACLE_SID=PRODB1 +export TOOLHOME=/opt/oracle/tools +export BACKUP_MEDIA=DISK +export BACKUP_TYPE=FULL_DB_BKUP +export MAXPIECESIZE=16G +# End of Configurable Section +# Start of site specific parameters +export BACKUP_MOUNTPOINT=/oraback +export DBAEMAIL="dbas@proligence.com" +export DBAPAGER="dba.ops@proligence.com" +export LOG_SERVER=prolin2 +export LOG_USER=oracle +export LOG_DIR=/dbalogs +export CATALOG_CONN=${ORACLE_SID}/${ORACLE_SID}@catalog +# End of site specific parameters +export LOC_PREFIX=$BACKUP_MOUNTPOINT/loc +export TMPDIR=/tmp +export NLS_DATE_FORMAT="MM/DD/YY HH24:MI:SS" +export TIMESTAMP=`date +%T-%m-%d-%Y` +export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib +export LIBPATH=$ORACLE_HOME/lib:/usr/lib:/lib +export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib:/lib +export LOG=${TOOLHOME}/log +LOG=${LOG}/log/${ORACLE_SID}_${BACKUP_TYPE}_${BACKUP_MEDIA}_${TIMESTAMP}.log +export TMPLOG=$TOOLHOME/log/tmplog.$$ +echo `date` "Starting $BACKUP_TYPE Backup of $ORACLE_SID \ +to $BACKUP_MEDIA" > $LOG +export LOCKFILE=$TOOLHOME/${ORACLE_SID}_${BACKUP_TYPE}_${BACKUP_MEDIA}.lock +if [ -f $LOCKFILE ]; then +echo `date` "Script running. Exiting ..." >> $LOG +else +echo "Do NOT delete this file. Used for RMAN locking" > $LOCKFILE +$ORACLE_HOME/bin/rman log=$TMPLOG <> $LOG +rm $LOCKFILE +echo `date` "Script lock file removed" >> $LOG +if [ $RC -ne "0" ]; then +mailx -s "RMAN $BACKUP_TYPE $ORACLE_SID $BACKUP_MEDIA Failed" \ +$DBAEMAIL,$DBAPAGER < $LOG +else +cp $LOG ${LOC_PREFIX}1 +mailx -s "RMAN $BACKUP_TYPE $ORACLE_SID $BACKUP_MEDIA Successful" \ +$DBAEMAIL < $LOG +fi +scp $LOG \ +${LOG_USER}@${LOG_SERVER}:${LOG_DIR}/${ORACLE_SID}/. +rm $TMPLOG +fi diff --git a/Chapter09/r_9_10.txt b/Chapter09/r_9_10.txt new file mode 100644 index 0000000..a58e38b --- /dev/null +++ b/Chapter09/r_9_10.txt @@ -0,0 +1,10 @@ +create script full_disk_db +comment 'Full Backup as Backupset to Disk' +{ +allocate channel c1 type disk +format 'c:\backup\rman_%U.rman'; +backup +database +include current controlfile; +release channel c1; +} diff --git a/Chapter09/r_9_2.txt b/Chapter09/r_9_2.txt new file mode 100644 index 0000000..6987595 --- /dev/null +++ b/Chapter09/r_9_2.txt @@ -0,0 +1,56 @@ +@ECHO OFF +:: Beginning of Script +:: Start of Configurable Section +set ORACLE_HOME=C:\oracle\product\10.2\db_1 +set ORACLE_SID=MOBDB10 +set TOOLHOME=C:\TOOLS +set BACKUP_MEDIA=DISK +set BACKUP_TYPE=FULL_DB_BKUP +set MAXPIECESIZE=16G +set BACKUP_MOUNTPOINT=c:\oracle\flash +set DBAEMAIL="dbas@proligence.com" +set DBAPAGER="dba.ops@proligence.com" +set CATALOG_CONN=%ORACLE_SID%/%ORACLE_SID%@catalog +set MS=mail.proligence.com +:: +:: end of Configurable Section +:: +set BACKUP_LOC_PREFIX=%BACKUP_MOUNTPOINT%\loc +set TMPDIR=C:\temp +set NLS_DATE_FORMAT="MM/DD/YY HH24:MI:SS" +realdate /d /s="set curdate=" > %TOOLHOME%\tmp_dt.bat +realdate /t /s="set curtime=" > %TOOLHOME%\tmp_tm.bat +call %TOOLHOME%\tmp_dt.bat +call %TOOLHOME%\tmp_tm.bat +:: +:: +set LOG=%TOOLHOME%\%ORACLE_SID%_%BACKUP_TYPE%_%BACKUP_MEDIA% ?_ +%CURDATE%_%CURTIME%.log +set TMPLOG=%TOOLHOME%\tmplog.$$ +:: +:: Build the Command File +set FORMATSTRING=%BACKUP_LOC_PREFIX%1\%ORACLE_SID%_%%u_%%p.rman +set CMDFILE=%TOOLHOME%\%ORACLE_SID%.rman +echo run { > %CMDFILE% +echo allocate channel c1 type disk >> %CMDFILE% +echo format '%FORMATSTRING%' >> %CMDFILE% +echo maxpiecesize %MAXPIECESIZE%; >> %CMDFILE% +echo backup >> %CMDFILE% +echo tablespace users; >> %CMDFILE% +echo release channel c1; >> %CMDFILE% +echo } >> %CMDFILE% +:: End of Command File Generation +:: +echo Starting the script > %LOG% +%ORACLE_HOME%\bin\rman target=/ catalog=%CATALOG_CONN% @%CMDFILE% ? +msglog=%TMPLOG% +:: +:: Merge the Logfiles +type %TMPLOG% >> %LOG% +:: Check for errors +:: +echo THE OUTPUT WAS %ERRORLEVEL% >> %LOG% +findstr /i "error" %LOG% +if errorlevel 0 if not errorlevel 1 bmail -s %MS% -t %DBAPAGER% ? +-f "Database" -m %LOG% +@echo on diff --git a/Chapter09/r_9_7.txt b/Chapter09/r_9_7.txt new file mode 100644 index 0000000..73fec9e --- /dev/null +++ b/Chapter09/r_9_7.txt @@ -0,0 +1,9 @@ +create script full_disk_db +{ +allocate channel c1 type disk +format 'c:\oracle\flash\loc1\rman_%U.rman'; +backup +database +include current controlfile; +release channel c1; +} diff --git a/Chapter09/r_9_8.txt b/Chapter09/r_9_8.txt new file mode 100644 index 0000000..80531c5 --- /dev/null +++ b/Chapter09/r_9_8.txt @@ -0,0 +1,11 @@ +create global script gs_arc_disk_bkup +comment 'Global Script to Backup Arc Logs Delete Input' +{ +allocate channel c1 type disk +format 'C:\oraback\%U.rman'; +backup +archivelog +all +delete input; +release channel c1; +} diff --git a/Chapter09/r_9_9.txt b/Chapter09/r_9_9.txt new file mode 100644 index 0000000..cda7eea --- /dev/null +++ b/Chapter09/r_9_9.txt @@ -0,0 +1,9 @@ +replace script full_disk_db +{ +allocate channel c1 type disk +format 'c:\backup\rman_%U.rman'; +backup +database +include current controlfile; +release channel c1; +} diff --git a/Chapter11/r_11_1.txt b/Chapter11/r_11_1.txt new file mode 100644 index 0000000..e204c64 --- /dev/null +++ b/Chapter11/r_11_1.txt @@ -0,0 +1 @@ +select file#, status, error,recover from v$datafile_header; diff --git a/Chapter11/r_11_4.txt b/Chapter11/r_11_4.txt new file mode 100644 index 0000000..7d8e79e --- /dev/null +++ b/Chapter11/r_11_4.txt @@ -0,0 +1,4 @@ +connect target / +startup mount; +restore database; +recover database test; diff --git a/Chapter11/r_11_8.txt b/Chapter11/r_11_8.txt new file mode 100644 index 0000000..9c68bac --- /dev/null +++ b/Chapter11/r_11_8.txt @@ -0,0 +1,8 @@ +run{ +set newname for datafile 4 to '/ora01/BRDSTN/data_ts01.dbf'; +set newname for datafile 5 to '/ora01/BRDSTN/data_ts02.dbf'; +restore tablespace data_ts; +switch datafile all; # Updates repository with new datafile location. +recover tablespace data_ts; +alter database open; +} diff --git a/Chapter11/r_11_intro_a.txt b/Chapter11/r_11_intro_a.txt new file mode 100644 index 0000000..af5b4b8 --- /dev/null +++ b/Chapter11/r_11_intro_a.txt @@ -0,0 +1,12 @@ +SELECT +a.thread#, b.open_mode, a.status, +CASE +WHEN ((b.open_mode='MOUNTED') AND (a.status='OPEN')) THEN 'Crash Recovery req.' +WHEN ((b.open_mode='MOUNTED') AND (a.status='CLOSED')) THEN 'No Crash Rec. req.' +WHEN ((b.open_mode='READ WRITE') AND (a.status='OPEN')) THEN 'Inst. already open' +ELSE 'huh?' +END STATUS +FROM v$thread a, +v$database b, +v$instance c +WHERE a.thread# = c.thread#; diff --git a/Chapter11/r_11_intro_b.txt b/Chapter11/r_11_intro_b.txt new file mode 100644 index 0000000..c991e3f --- /dev/null +++ b/Chapter11/r_11_intro_b.txt @@ -0,0 +1,13 @@ +SELECT +a.name, +a.checkpoint_change#, +b.checkpoint_change#, +CASE +WHEN ((a.checkpoint_change# - b.checkpoint_change#) = 0) THEN 'Startup Normal' +WHEN ((a.checkpoint_change# - b.checkpoint_change#) > 0) THEN 'Media Recovery' +WHEN ((a.checkpoint_change# - b.checkpoint_change#) < 0) THEN 'Old Control File' +ELSE 'what the ?' +END STATUS +FROM v$datafile a, -- control file SCN for datafile +v$datafile_header b -- datafile header SCN +WHERE a.file# = b.file#; diff --git a/Chapter12/r_12_2.txt b/Chapter12/r_12_2.txt new file mode 100644 index 0000000..a16a28f --- /dev/null +++ b/Chapter12/r_12_2.txt @@ -0,0 +1,7 @@ +connect target / +startup mount; +restore database until time + "to_date('05-oct-2006 14:00:00', 'dd-mon-rrrr hh24:mi:ss')"; +recover database until time + "to_date('05-oct-2006 14:00:00', 'dd-mon-rrrr hh24:mi:ss')"; +alter database open resetlogs; diff --git a/Chapter12/r_12_3.txt b/Chapter12/r_12_3.txt new file mode 100644 index 0000000..0d88d52 --- /dev/null +++ b/Chapter12/r_12_3.txt @@ -0,0 +1,7 @@ +select sequence#, first_change#, first_time +from v$log_history +order by first_time; + +select sequence#, first_change#, first_time +from v$archived_log +order by first_time; diff --git a/Chapter12/r_12_intro_a.txt b/Chapter12/r_12_intro_a.txt new file mode 100644 index 0000000..eecac08 --- /dev/null +++ b/Chapter12/r_12_intro_a.txt @@ -0,0 +1,3 @@ +select file#, status, checkpoint_change#, +to_char(checkpoint_time,'dd-mon-rrrr hh24:mi:ss') +from v$datafile_header; diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..c903596 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2007 Sam Alapati, Darl Kuhn, and Arup Nanda + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e889b17 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*RMAN Recipes for Oracle Database 11g*](http://www.apress.com/9781590598511) by Sam Alapati, Darl Kuhn, and Arup Nanda (Apress, 2007). + +![Cover image](9781590598511.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..f79b6c0 --- /dev/null +++ b/README.txt @@ -0,0 +1,14 @@ +This is the README.txt for RMAN Recipes for Oracle Database 11g, first edition. + +The scripts are located in the Chapter folders. For the most part, we used +this naming convention: + +r_11_1.txt (indicates recipe 11.1) +r_11_2.txt (indicates recipe 11.2) + +If you have any questions, corrections, or suggestions, please email +me directly at: + +darl.kuhn@gmail.com + +thanks. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file