# DCasbr.ctl:305:Collects Application Server 10g Backup and Recovery Information # $Id: DCasbr.ctl,v 1.9 2013/11/05 14:18:00 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/DCasbr.ctl,v 1.9 2013/11/05 14:18:00 RDA Exp $ # # Change History # 20131105 MSC Improve code consistency. =head1 NAME OFM:DCasbr - Collects Application Server 10g Backup and Recovery Information. =head1 DESCRIPTION This module collects the Application Server 10g backup and recovery-related information. It should not be used against Oracle Fusion Middleware 11g or later. The following reports can be generated and are regrouped under C: =head1 REPORTS =cut echo tput('bold'),'Processing OFM.ASBR module ...',tput('off') # Initialization var $ORACLE_HOME = ${D_ORACLE_HOME/P:''} var $ASBR_HOME = catDir($ORACLE_HOME,'backup_restore') var $DCM_HOME = catDir($ORACLE_HOME,'dcm') var $MOD = cond(isUnix(),'fx','fr') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' pretoc '1:AS Backup/Recovery' set $NOT_OWNER_STATEMENT {**Note:** " "The RDA was executed with an operating system user which is different from "the operating system user who installed the Oracle Application Server. " "Therefore, no information are available in this section. " } # Load the common macros run RDA:library() # Set the required environment var $bkp = setContext({PERL5LIB => ${ENV.PERL5LIB},\ PERL5OPT => ${ENV.PERL5OPT}}) =head2 db_info - Database Information Gathers the Application Server backup and recovery information from the database. Depending on the database version, it can collect data from C, C, and C. =cut if ${I_DB} {call setSqlTarget(last) # Load the common macros run DB:DBinfo() # Test the database connection and collect the information if testSql() {echo '' echo tput('bold'),'The database is not accessible.',tput('off') if getSqlMessage() echo last echo '' } else {var $ver = get_db_version() debug ' Inside ASBR module, gathering database information' report db_info var $TTL = '---+!! Application Server Backup/Recovery Database Information' if match($ver,'^(10|11|12)') {var @TTL = ('',\ '---+ Database Information',\ '---+ Recovery File Destination',\ '---+ Flash Recovery Area Usage') var @HDR = ('',\ '|*Name*|*Log Mode*|*Open Mode*|*Flashback On*|', \ '|*Name*| *Space Limit*| *Space Used*| *Space Reclaimable*| \ *Number of Files*|',\ '|*File Type* | *Used(MiB)*| *Reclaimable(MiB)*| \ *Number of Files*|') set $sql {SELECT '|' || " name || ' |' || " log_mode || ' |' || " open_mode || ' |' || " flashback_on || ' |' " FROM v$database; "PROMPT ___Macro_separator(2)___ "SELECT '|' || " name || ' |' || " space_limit || '| ' || " space_used || '| ' || " space_reclaimable || '| ' || " number_of_files || '| ' " FROM v$recovery_file_dest; } if match($ver,'^(102$|11|12)') {append $sql {PROMPT ___Macro_separator(3)___ "SELECT '|' || " f.file_type || ' | ' || " ROUND(r.space_used * f.percent_space_used / 104857600,1) || '| ' || " ROUND(r.space_reclaimable * f.percent_space_reclaimable / " 104857600,1) || '| ' || " f.number_of_files || '| ' " FROM v$recovery_file_dest r,v$flash_recovery_area_usage f; } } } elsif match($ver,'^(81|9)') {var @TTL = ('','---+ Database Information') var @HDR = ('','|*Name*|*Log Mode*|*Open Mode*|') set $sql {SELECT '|' || " name || ' |' || " log_mode || ' |' || " open_mode || ' |' || " FROM v$database; } } elsif match($ver,'^(80|7)') {var @TTL = ('','---+ Database Information') var @HDR = ('','|*Name*|*Log Mode*|') set $sql {SELECT '|' || " name || ' |' || " log_mode || ' |' || " FROM v$database; } } if $sql {call separator(1) call writeSql($sql) call separator(0,'Database Information') } } } =head2 scripts - Backup Script Results Collects the backup list, instance backup list, and changed configuration files by executing the backup and restore scripts. =cut debug ' Inside ASBR module, gathering backup/restore scripts results' report scripts prefix {write '---+!! Output of Backup Restore Scripts' write $TOC } if ?testFile($MOD,$pgm = catFile($ASBR_HOME,${AB.BAT:'bkp_restore'})) {var %ttl = ('list_backups', '---+ Backup List',\ 'list_instance_backups','---+ Instance Backup List',\ 'list_changed_config', '---+ Changed Configuration Files') loop $opt ('list_backups','list_instance_backups','list_changed_config') {var $cmd = concat(lastCommand(),' -m ',$opt) write $ttl{$opt} write '---## Using: ',encode($cmd) call writeCommand($cmd) write $TOP } } elsif ?testFile('f',$pgm) {write '** ',encode($pgm),' is not executable.**%BR%\ Permissions are as following:%BR%' call statFile('b',$pgm) } if isCreated() toc '2:[[',getFile(),'][rda_report][Backup Script Results]]' =head2 dcm_archives - DCM archives Collects the list of DCM archives. =cut if ?testFile('f',catFile($ORACLE_HOME,'dcm','bin',${AS.EXE:'dcmctl'})) {var $dcm = last # Define a macro do get dcmctl output macro get_dcmshell {var ($cmd,$cod,$msg) = @arg import $TOP var $err = getTemp('err') var $in = createTemp('in') call writeTemp('in',$cod) call writeTemp('in','exit') call closeTemp('in') write '---## Using in dcmctl shell: ',encode($cod) call loadCommand(concat($cmd," shell <",$in," 2>",$err)) var @tbl = getLines() if @tbl {write '' loop $lin (@tbl) write replace($lin,'dcmctl>\s*') write '' write $TOP } elsif $msg write $msg if ?testFile('s',$err) {write '**Exception from "',encode($cmd),'"**%BR%' call writeFile($err) } call unlinkTemp('in') call unlinkTemp('err') } # Produce the report debug ' Inside ASBR module, gathering DCM Archive files' report dcm_archives write '---+ DCM Archives' toc '2:[[',getFile(),'][rda_report][DCM Archives]]' var $pgm = testFile('f',catFile($ORACLE_HOME,'opmn','bin',${AS.EXE:'opmnctl'})) var $uid = getOwner(getToc(true)) var $own = getOwner($pgm) if compare('ne',$uid,$own) {echo tput('reverse'),'Warning:' echo '========' echo 'The RDA was started as userid: ',$uid echo 'Oracle Application Server was installed on your system using userid: ',\ nvl($own,'[not found]') echo 'The RDA script will continue, but it will skip some collections.',\ tput('off') write $NOT_OWNER_STATEMENT } elsif grepCommand(concat(quote($pgm),' status process-type=dcm-daemon'),\ 'alive','if') call get_dcmshell(quote($dcm),'listArchives','No Archives Found') else write '**Note:** DCM is not running' } =head2 Configuration Files Collects all files from the F directory. =cut debug ' Inside ASBR module, gathering configuration files' pretoc '2:Configuration Files' var $dir = catDir($ASBR_HOME,'config') if ?testDir('d',$dir) call sort_files(3,0,grepDir($dir,'.*','pn')) unpretoc =head2 config_backup_path - Configuration Backup Path Contents Lists the contents of configuration backup path. =cut debug ' Inside ASBR module, listing config_backup_path directory contents' call loadFile(catFile($dir,'config.inp')) if grepLastFile('^config_backup_path=','f') {if and(length($dir = value(last)),\ testDir('d',$dir = catDir($dir))) {report config_backup_path prefix write '---+ Configuration Backup Path Directory Contents' loop $fil ($dir,grepDir($dir,'^[\.]+$','vr')) {if ?testDir('d',$fil) call statDir('an',$fil) } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Configuration Backup Path Contents]]' } } =head2 database_backup_path - Database Backup Path Contents Lists the contents of database backup path. =cut debug ' Inside ASBR module, listing database_backup_path directory contents' if grepLastFile('^database_backup_path=','f') {if and(length($dir = value(last)),\ testDir('d',$dir = catDir($dir))) {report database_backup_path prefix write '---+ Database Backup Path Directory Contents' loop $fil ($dir,grepDir($dir,'^[\.]+$','vr')) {if ?testDir('d',$fil) call statDir('an',$fil) } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Database Backup Path Contents]]' } } =head2 Log Files Collects the log files. =cut debug ' Inside ASBR module, gathering log files' pretoc '2:Log Files' if grepLastFile('^log_path=','f') var $dir = value(last) else var $dir = undef if length($dir) call sort_files(3,0,grepDir(catDir($dir),'.*','pn')) else call sort_files(3,0,grepDir(catDir($ASBR_HOME,'logs'),'.*','pn')) unpretoc =head2 not_found - Not Found Used as a warning when no Application Server Backup Recovery information is found. =cut if !isTocCreated() {debug ' Inside ASBR module, no information found' report not_found write 'No Application Server Backup Recovery information was found. This \ does not mean there was necessarily a problem with RDA, but it should \ be investigated.' toc '2:[[',getFile(),'][rda_report][Not Found]]' } # Restore the previous environment call restoreContext($bkp) =head1 SEE ALSO L, L =begin credits =over 10 =item RDA 4.10: Daniel Mortimer. =item RDA 4.20: Daniel Mortimer. =item RDA 8.00: Daniel Mortimer. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. =head1 TRADEMARK NOTICE Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. =cut