Thursday, 13 September 2018

FIND BACKUP RMAN HISTORY:


  1. SQL> col STATUS format a9  
  2. SQL> col hrs format 999.99  
  3. SQL> select SESSION_KEY, INPUT_TYPE, STATUS, 
  4. to_char(START_TIME,'mm/dd/yy hh24:mi')
  5. start_time, to_char(END_TIME,'mm/dd/yy hh24:mi') end_time,
  6.  elapsed_seconds/3600 hrs
  7.  from V$RMAN_BACKUP_JOB_DETAILS order by session_key;  


RMAN SIZE AND TIMINGS:


col "Total Time" for a30;
col size for a30;
set lines 999;

select session_key "Session",
       input_type "Type",
       status "Status",
       to_char(start_time,'yyyy-mm-dd hh24:mi') "Start Time",
       to_char(end_time,'yyyy-mm-dd hh24:mi')  "End Time",
       output_bytes_display "Size",
       time_taken_display "Total Time"
from v$rman_backup_job_details
where to_char(end_time,'yyyy-mm-dd hh24:mi') >= to_char(sysdate-7,'yyyy-mm-dd hh24:mi') 
and STATUS='COMPLETED'
order by session_key asc;


col TYPE for a20 Heading "Backup Type"
col completion_time Heading "Completion Time"
col MB for 99999999999  Heading "Size (MB)"
col BCPTIME for 99999999999 Heading "Backup Time (minutes)"

SELECT TO_CHAR (completion_time, 'YYYY-MON-DD') completion_time
       , TYPE
       , ROUND (SUM (bytes) / 1048576)          MB
       , ROUND (SUM (elapsed_seconds) / 60)     BCPTIME
    FROM (SELECT CASE
                    WHEN s.backup_type = 'L' THEN 'Archive Log'
--                    WHEN s.controlfile_included = 'YES' THEN 'Control File'
                 WHEN s.backup_type = 'D' THEN 'Full (Level ' || NVL (s.incremental_level, 0) || ')'
                    WHEN s.backup_type = 'I' THEN 'Incemental (Level ' || s.incremental_level || ')'
                    ELSE s.backup_type
                 END
                    TYPE
               , TRUNC (s.completion_time) completion_time
               , p.tag
               , p.bytes
               , s.elapsed_seconds
            FROM v$backup_piece p, v$backup_set s
           WHERE status = 'A' AND p.recid = s.recid
          UNION ALL
          SELECT 'Datafile Copy' TYPE, TRUNC (completion_time), tag, output_bytes, 0 elapsed_seconds FROM v$backup_copy_details)
GROUP BY tag, TO_CHAR (completion_time, 'YYYY-MON-DD'), TYPE
ORDER BY 1 ASC, 2, 3;

No comments:

Post a Comment