MAX_RMAN_08137_IGNORE=5 DISK_RETENTION_POLICY='RECOVERY WINDOW OF 7 DAYS'

Similar documents
RMAN What is Rman Why use Rman Understanding The Rman Architecture Taking Backup in Non archive Backup Mode Taking Backup in archive Mode

Strategies for Oracle Database Backup and Recovery: Case Studies. Mingguang Xu

11. Oracle Recovery Manager Overview and Configuration.

HOW TO. RMAN Restore for Standby 10gR2

Using RMAN to restore a database to another server in an ASM environment

BrightStor ARCserve Backup

Configuring Backup Settings. Copyright 2009, Oracle. All rights reserved.

12. User-managed and RMAN-based backups.

Agenda. Overview Configuring the database for basic Backup and Recovery Backing up your database Restore and Recovery Operations Managing your backups

Oracle 10g Feature: RMAN Incrementally Updated Backups

RMAN BACKUP & RECOVERY. Recovery Manager. Veeratteshwaran Sridhar

Oracle 12c Recovering a lost /corrupted table from RMAN Backup after user error or application issue

TECHNICAL REPORT. Nimble Storage Oracle Backup and Recovery Guide

Oracle 11gR2 : Recover dropped tablespace using RMAN tablespace point in time recovery

RMAN for Commando DBAs. By Charles Kim

RMAN Recipes for Oracle Database 11g : A Problem-Solution Approach by Darl Kuhn, Sam Alapati and Arup Nanda Apress. (c) Copying Prohibited.

Backup/Restore Oracle 8i/9i/10g

Getting all the pieces: Reliable Backup/Recovery

Recreate Physical Standby Database after Recovery of Primary Database

Use RMAN to relocate a 10TB RAC database with minimum downtime. Tao Zuo tao_zuo@npd.com NPD Inc. 9/2011

Database Recovery For Newbies

Demos - Workshop. -- Configure the RMAN

This appendix describes the following procedures: Cisco ANA Registry Backup and Restore Oracle Database Backup and Restore

Oracle Recovery Manager

Oracle Data Recovery Advisor

Restore and Recovery Tasks. Copyright 2009, Oracle. All rights reserved.

Oracle Database 11g: Administration Workshop II DBA Release 2

Configuring Backup Settings Configuring and Managing Persistent Settings for RMAN Configuring Autobackup of Control File Backup optimization

Oracle Database 11g: Administration Workshop II DBA Release 2

HP LeftHand SAN Solutions

11. Configuring the Database Archiving Mode.

Oracle Database 11g: Administration Workshop II Release 2

RMAN in the Trenches: To Go Forward, We Must Backup

Database Disaster Recovery using only RMAN Backups

Oracle Backup and Recovery Best Practices Dell Compellent Storage Center. Dell Compellent Technical Best Practices

If you have not multiplexed your online redo logs, then you are only left with incomplete recovery. Your steps are as follows:

ORACLE CORE DBA ONLINE TRAINING

DOCUMENTATION ORACLE BACKUP & RESTORE OPERATIONS

Oracle Database Backups and Disaster Autodesk

Oracle Database 10g: Backup and Recovery

Backup and Recovery. Oracle RMAN 11 g. Oracle Press ORACLG. Matthew Hart. Robert G. Freeman. Mc Graw Hill. Lisbon London Madrid Mexico City Milan

Oracle Data Guard. Caleb Small Puget Sound Oracle Users Group Education Is Our Passion

Restoring To A Different Location With EBU And RMAN An AppsDBA Consulting White Paper

Oracle Database 10g: Backup and Recovery 1-2

Oracle. Brief Course Content This course can be done in modular form as per the detail below. ORA-1 Oracle Database 10g: SQL 4 Weeks 4000/-

! " # #$ " " %" & "'( " "' ( ) " * ""! ). " / ( * ( "# 0! " ). '

Oracle Database B

OCP: Oracle Database 12c Administrator Certified Professional Study Guide. Exam 1Z0-063

Using Recovery Manager with Oracle Data Guard in Oracle Database 10g. An Oracle White Paper April 2009

Backing Up Oracle Databases with Handy Backup

Using Recovery Manager with Oracle Data Guard in Oracle9i. An Oracle White Paper January 2007

Oracle Recovery Manager 10g. An Oracle White Paper November 2003

sqlcmd -S.\SQLEXPRESS -Q "select name from sys.databases"

Oracle9i Database: Advanced Backup and Recovery Using RMAN

WHITE PAPER. Oracle RMAN Design Best Practices with Data Domain. Storage. Deduplication

Oracle Backup and Recover 101. Osborne Press ISBN

Setting up the Oracle Warehouse Builder Project. Topics. Overview. Purpose

Backing up and restoring HP Systems Insight Manager 6.0 or greater data files in a Windows environment

ORACLE DATABASE 11G: COMPLETE

Performing Database and File System Backups and Restores Using Oracle Secure Backup

Zen Internet. Online Data Backup. Zen Vault Professional Plug-ins. Issue:

The safer, easier way to help you pass any IT exams. Exam : 1Z Upgrade Oracle9i/10g/11g OCA to Oracle Database 12c OCP.

Maximum Availability Architecture. Oracle Best Practices For High Availability

How to Best Configure, Size, and Monitor the Oracle Database Fast Recovery Area

Oracle Database 10g: Administration Workshop II Release 2

Oracle Database 12c Recovery Manager New Features

ORACLE RMAN DESIGN BEST PRACTICES WITH EMC DATA DOMAIN

Symantec Backup Exec 2014 Icon List

ASM and for 3rd Party Snapshot Solutions - for Offhost. Duane Smith Nitin Vengurlekar RACPACK

HP Data Protector 7.00 Integration Guide for Oracle and SAP

Oracle 11g Database Administration

Cross Platform Transportable Tablespaces Migration in Oracle 11g

Oracle Data Guard for High Availability and Disaster Recovery

D12CBR Oracle Database 12c: Backup and Recovery Workshop NEW

<Insert Picture Here> RMAN Configuration and Performance Tuning Best Practices

Oracle Database 11g: Administration Workshop I Release 2

Using HP StoreOnce Backup systems for Oracle database backups

Oracle Backup, Recovery, and Performance Tuning using EMC Avamar and Oracle RMAN

Automatic Backup in Oracle Database

Using Physical Replication and Oracle Database Standard Edition for Disaster Recovery. A Dbvisit White Paper

Administration GUIDE. SharePoint Server idataagent. Published On: 11/19/2013 V10 Service Pack 4A Page 1 of 201

An Oracle White Paper January Protecting SPARC SuperCluster Tape Backup with Symantec NetBackup

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

How To Backup And Restore A Database With A Powervault Backup And Powervaults Backup Software On A Poweredge Powervalt Backup On A Netvault 2.5 (Powervault) Powervast Backup On An Uniden Power

Backing Up CNG SAFE Version 6.0

Oracle 11g DBA Training Course Content

Database Administration

Oracle security done right. Secure database access on the (unix and linux) operating system level.

How to Change the Server Hostname

SAP with Oracle Real Application Clusters 11g Release 2 and Oracle Automatic Storage Management 11g Release 2

High Performance Oracle RAC Clusters A study of SSD SAN storage A Datapipe White Paper

ADSMConnect Agent for Oracle Backup on Sun Solaris Installation and User's Guide

Backup Types. Backup and Recovery. Categories of Failures. Issues. Logical. Cold. Hot. Physical With. Statement failure

Oracle Database 11g: Administration Workshop I Release 2

SAP Note FAQ: SAP HANA Database Backup & Recovery

Why Not Oracle Standard Edition? A Dbvisit White Paper By Anton Els

Transcription:

!/bin/sh Example shell script to perform a nightly full backup of the database and scan for errors Copyright (c) 2008, 2014 Caleb.com All Rights Reserved This script is provided as an EXAMPLE ONLY and is NOT SAFE to run anywere except an expendable test system. Do not invoke the script with dot-slash, it will not work with RMAN's msgle, use a full path, for example: /home/oracle/rman_backup.sh The oracle environment must be set, including ORACLE_HOME, ORACLE_SID and PATH Run as the oracle user Return code is set at the end to indicate complete success or failure A time and date named log le is generated in the script directory RMAN-08137: is expected behaviour in a DataGuard environment and is ignored It may be desirable to also lter the following errors : RMAN-08138: is a byproduct of using an archive log deletion policy -------------------------------------------------------------------------------- Initialization section - set or get parameters for backup -------------------------------------------------------------------------------- Set the maximum number of RMAN-08137 errors to ignore, if exceeded all are reported MAX_RMAN_08137_IGNORE=5 Dene retention policies to be used for deleting obsolete backups eg. 'REDUNDANCY n' or 'RECOVERY WINDOW OF n DAYS' This does NOT set the persistent setting, only what is deleted by this script! TEST! - set retention policy appropriately for production (eg. 7 and 31 days) DISK_RETENTION_POLICY='RECOVERY WINDOW OF 7 DAYS' Generate a unique log le name and initialize LOGFILE=${0}_`date +%F:%T`_$HOSTNAME\_$ORACLE_SID.out echo -e "\n***\n*** Backup script started at `date`\n***\n" >> $LOGFILE chmod 666 $LOGFILE Scan and error les are for temporary output TMPFILE=${0}_TMPFILE_$HOSTNAME\_$ORACLE_SID.out ERRFILE=${0}_ERRFILE_$HOSTNAME\_$ORACLE_SID.out Set NLS parameters to keep output readable export NLS_DATE_FORMAT='dd-mon-yy hh24:mi:ss' export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 The backups will be taged so they can be easily identied for reporting. The prex will indicate the backup type (eg. DB incremental level, archive log or control/sple). The sufx is a numeric time and date stamp to uniquely identify this backup. The teme/date stamp is the same for all steps of this backup and indicates the backup start time. _TAG_SUFFIX="`date +%y%m%d_%h%m`" -------------------------------------------------------------------------------- Perform the RMAN backup to disk -------------------------------------------------------------------------------- Build command string to execute RMAN The backup itself is in three separate pieces for manageability, and the fact that we want one last control le backup with an up-to-date repository AFTER everything is nished. The CHECK LOGICAL opton is used to perform validation of the database on the way out. INCREMENTAL LEVEL 0 is used to pave the way for possible future incremental backups, it is equivalent to a full backup. It is important to verify the persistent settings. Other people can mess with these, so at minimum we should know what they are, and we should probably explicitly set them to known values here to override any outside changes. Adjust the retention policy as desired, and refer to discussion about recovery -1-

window vs. redundancy. The specication in the delete obsolete command overrides the persistent setting, but doesn't stop someone from deleting outside this script, or Oracle from reclaiming space as necessary - this will go by the persistent setting. There is a lot of controversy over both the crosscheck and the delete obsolete. I maintain that the crosscheck backup is valid and necessary to identify missing les, and the crosscheck alone (without delete expired) does no harm. Without the crosscheck, REPORT NEED would miss datales who's backup has gone missing, and remaining older good copies would be deleted as obsolete. However, crosscheck archivelog should NOT EVER be used in the script because it will silently allow the backup to proceed with missing archive logs! Similarly, DO NOT use SKIP INACCESSIBLE in the backup script. Delete obsolete is arguable, I like it to keep the FRA cleaned out so I can "see" how much free space there is. By deleting old backups that have past the retention policy it is remotely conceivable that we are loosing a slim "last resort" recovery position if all our "good" backups are corrupt or missing. The use of DELETE INPUT (and NOT delete ALL input) is the best way to manage archive logs. This will delete one copy of each archive log after it is backed up, and only of DataGuard does not still need it. Time based or manual methods can delete archive logs still required for gap resolution thus destroying a standby DB. FILESPERSET is also arguable, some say it should be 1 to speed up restore of a single le, the values here are a compromise to keep the number of individual backup set pieces manageable. One last note: this backup strategy is absolutely NOT appropriate for a data de-duplication device (eg. DataDomain). It requires an entirely different set of parameters, otherwise de-duplication will NOT occurr as expected. CMD_STR=" rman target / nocatalog msglog $LOGFILE append << EOF Verify persistent settings SHOW ALL; Crosscheck for missing les and delete obsolete FRA les. ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK; CROSSCHECK DEVICE TYPE DISK; HOST 'echo -e \"\n\nlisting EXPIRED Backups...\n==========================\n\"'; LIST EXPIRED ; HOST 'echo -e \"\n\ndeleting OBSOLETE Backups...\n============================\n\"'; DELETE NOPROMPT OBSOLETE $DISK_RETENTION_POLICY DEVICE TYPE DISK; RELEASE CHANNEL; Perform the backup in three individual steps: database, archivelogs and controlle RUN { Step 1: Backup the database to the Flash Recovery Area ALLOCATE CHANNEL ds00 DEVICE TYPE DISK MAXPIECESIZE 32G; ALLOCATE CHANNEL ds01 DEVICE TYPE DISK MAXPIECESIZE 32G; ALLOCATE CHANNEL ds02 DEVICE TYPE DISK MAXPIECESIZE 32G; ALLOCATE CHANNEL ds03 DEVICE TYPE DISK MAXPIECESIZE 32G; Backup the database according to the incremental level specication AS COMPRESSED SET CHECK LOGICAL INCREMENTAL LEVEL 0 TAG 'DATABASE_${_TAG_SUFFIX}' -2-

FILESPERSET 5 DATABASE; Although this may be redundant, ensure any archive logs written during the DB backup are archived (including RAC) SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT'; Step 2: Backup the archive logs as a separate operation so the backup sets can have their own unique tags AS COMPRESSED SET CHECK LOGICAL TAG 'ARCHIVELOG_${_TAG_SUFFIX}' FILESPERSET 20 ARCHIVELOG ALL DELETE INPUT; Step 3: Make one nal copy of the control le to ensure all just completed backup information is included TAG 'CONTROLFILE_`date +%y%m%d_%h%m`' CURRENT CONTROLFILE SPFILE; RELEASE CHANNEL ds00; RELEASE CHANNEL ds01; RELEASE CHANNEL ds02; RELEASE CHANNEL ds03; } Check to see if anything is unrecoverable REPORT SCHEMA; REPORT UNRECOVERABLE; REPORT NEED ; LIST SUMMARY; EOF " Execute RMAN and capture the return code echo -e "\n***\n*** The following is the RMAN backup command to be executed\n***\n" >> $LOGFILE echo "$CMD_STR" >> $LOGFILE echo -e "\n***\n*** The following is output of the RMAN backup command\n***\n" >> $LOGFILE /bin/sh -c "$CMD_STR" >> $LOGFILE EXIT_STAT=$CMD_STAT Test the return code LOGMSG="successfully" LOGMSG="in error" Log completion message echo Recovery Manager ended $LOGMSG >> $LOGFILE Perform a separate manual backup of the control and sple This is especially important if we are NOT using a recovery catalog so that there is an easy to nd copy of the control le with RMAN repository. -3-

Also, display information about the FRA conguration, space utilization, control le location and nally the precious DBID if we have to do a full restore! CMD_STR=" sqlplus / as sysdba >> $LOGFILE << EOF ALTER DATABASE CONTROLFILE TO TRACE; ALTER DATABASE CONTROLFILE TO TRACE AS '$ORACLE_HOME/dbs/controlle_trace_$ORACLE_SID.backup' REUSE; ALTER DATABASE CONTROLFILE TO '$ORACLE_HOME/dbs/controlle_$ORACLE_SID.backup' REUSE; CREATE PFILE='$ORACLE_HOME/dbs/ple_$ORACLE_SID.backup' FROM SPFILE; SELECT * FROM v\\\$flash_recovery_area_usage; SHOW PARAMETER recovery SHOW PARAMETER control_le SELECT dbid FROM v\\\$database; EXIT EOF " Execute SQL*Plus command and capture return code echo -e "\n***\n*** The following is the SQL command to be executed\n***\n" >> $LOGFILE echo "$CMD_STR" >> $LOGFILE echo -e "\n***\n*** The following is output of the SQL command\n***\n" >> $LOGFILE /bin/sh -c "$CMD_STR" >> $LOGFILE Test the return code LOGMSG="successfully" LOGMSG="in error" EXIT_STAT=$CMD_STAT Log completion message echo Control File + SPle manual backup ended $LOGMSG >> $LOGFILE -------------------------------------------------------------------------------- Scan the log le for errors and report here -------------------------------------------------------------------------------- This is where we should be sending an email to the DBA announcing the status of the backup job, and reporting any errors detected NOTE the following RMAN error message is expected behavour with DataGuard: RMAN-08137: WARNING: archive log not deleted as it is still needed This may trigger unnecessary error return codes from this script, however, If we simply ignore it, we could be missing a potentially serious condition if none of the archive logs are being deleted because of a gap problem If there are just a few RMAN-08137 errors, ignore them if [ `grep -c RMAN-08137 $LOGFILE` -gt $MAX_RMAN_08137_IGNORE ] cat $LOGFILE > $TMPFILE sed '/RMAN-08137/d' $LOGFILE > $TMPFILE Scan the logle for remaining errors egrep -i "ORA- RMAN- TNS- PLS- PROT- ERROR WARNING FAILED 'EXPIRED'" -B 3 -A 3 $TMPFILE > $ERRFILE Produce the error summary with a header to make it visually obvious -4-

echo "***********************************************************************************" >> $LOGFILE echo Error summary follows >> $LOGFILE echo "***********************************************************************************" >> $LOGFILE If the return code is 0 egrep found something, log the result and set the return code echo Errors detected in log le >> $LOGFILE cat $ERRFILE >> $LOGFILE EXIT_STAT=1 echo NO errors detected in log le, manual review suggested >> $LOGFILE Set the nal return code for exit echo -e "\n***\n*** Backup script ended at `date`\n***\n" >> $LOGFILE echo Exiting with return code $EXIT_STAT >> $LOGFILE Send an email with status of the backup If there were errors, they will be included in the body of the email if [ "$EXIT_STAT" == "0" ] SUBJECT="Oracle Backup SUCCEEDED on `hostname`" SUBJECT="Oracle Backup FAILED on `hostname`" Substitute your own email script command here /g01/scripts/your_sendmail_scipt_here.pl "$ERRFILE" "$FROM" "$SUBJECT" "$TO" exit $EXIT_STAT Copyright (c) 2008, 2014 Caleb.com All Rights Reserved. -5-