I started reviewing recovery scenarios and realized that if I ever had to do a complete database loss recovery without my recovery catalog, determining my DBID would be problematic. So I did a little shell scripting and came up with a simple solution at the OS level. This is written for bash, on Linux, and assumes you can receive email from the server. A simple way to confirm this is to type echo “Test” | mail -s “Email Test” dba@yourcomany.com and see if it gets through. If it doesn’t, check to see if sendmail is running (#service sendmail status), or consult your system admins. Anyway, here’s the script:
cat incarnation.sh
# source your ORACLE_HOME that rman runs out of, however you do that
. /u01/appprod/oracle/proddb/11.1.0/PROD_myserver.env
RCATUSER=whatever your recovery catalog user is
RCATPASS=whatever your recovery catalog user password is
DBA=your email
# really only necessary if you’re not running this script out of the recovery catalog home
REPSID=SID of your recovery catalog
echo “list incarnation;”|rman catalog ${RCATUSER}/${RCATPASS}@${REPSID} | mail -s “RMAN DBIDs” $DBA
Now you can cron it up (crontab -e) and in the case below you’ll be updated every weekday @ 8am:
# email me the DBIDs every weekday
0 8 * * 1-5 /scratch/oracle/dba/scripts/incarnation.sh > /dev/null
Your email will look something like this:
Recovery Manager: Release 11.1.0.7.0 - Production on Thu Jul 9 15:39:21 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to recovery catalog database
RMAN>
List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time ------- ------- -------- ---------------- --- ---------- ---------- 23832 23839 ADV_TRN 292427552 PARENT 1 05-FEB-06 23832 23833 ADV_TRN 292427552 CURRENT 440636 02-MAY-07 46144 46151 ADV_TEST 491394006 PARENT 1 05-FEB-06 46144 46145 ADV_TEST 491394006 CURRENT 440636 11-JUL-07 46214 46221 AAD_TEST 914518601 PARENT 1 05-FEB-06 46214 46215 AAD_TEST 914518601 CURRENT 440636 12-JUL-07 ...
There may be a more elegant way to do this, but I couldn’t find one. I would have preferred this to be an EM job, except there is no option under RMAN scripts to connect to the recovery catalog only (you must select at least 1 target).
