Friday, July 5, 2013

RMAN Backup/Restore Progress

Before restoring or cloning a database to find backup pieces that are required for:
RMAN> list backup of database completed before "to_date('03/07/2013 23:59','DD/MM/YY HH24:MI:SS')";

This gives the list of backups. From this give the time required for database to restore in run block

Restore Progress: Works at Moutn state.
SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK, 
ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE" 
FROM V$SESSION_LONGOPS 
WHERE OPNAME LIKE 'RMAN%' 
AND OPNAME NOT LIKE '%aggregate%' 
AND TOTALWORK != 0 
AND SOFAR <> TOTALWORK 

SELECT sid, serial#, context, sofar, totalwork,

            round(sofar/totalwork*100,2) "% Complete"

     FROM v$session_longops

     WHERE opname LIKE 'RMAN%'

     AND opname NOT LIKE '%aggregate%'

     AND totalwork != 0

     AND sofar <> totalwork;
or you can use a query against the v$ view: v$backup_async_io
select device_type "Device", type, filename, to_char(open_time, 'mm/dd/yyyy hh24:mi:ss') open,

to_char(close_time,'mm/dd/yyyy hh24:mi:ss') close,elapsed_time ET, effective_bytes_per_second EPS

from v$backup_async_io
References (Metalink):
237083.1 - Using V$BACKUP_ASYNC_IO / V$BACKUP_SYNC_IO to Monitor RMAN Performance: https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=237083.1

109159.1 - RMAN: Checking the Progress of RMAN Backup/Recovery: https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=109159.1

144640.1 - RMAN: Monitoring Recovery Manager Jobs: https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=144640.1


=========================================================================
Output of the script:

$ . oraenv
$ bash rman_duplicate_monitor_eta.sh 
 
-------- RMAN: timing information - Tue May 15 22:05:47 EST 2012 ---------- 
 
OPNAME                              SOFAR  TOTALWORK   PCT_DONE    ELA_MIN    ETA_MIN START_TIME          FINISH_TIME 
------------------------------ ---------- ---------- ---------- ---------- ---------- ------------------- ------------------- 
RMAN: incremental datafile bac        638        656      97.26          1          0 15-05-2012 22:02:30 15-05-2012 22:05:47 
RMAN: aggregate input              737488     738214       99.9        5.2          0 15-05-2012 21:59:13 15-05-2012 22:05:47 
RMAN: incremental datafile bac        640          0        100          1            15-05-2012 22:02:30 
RMAN: aggregate output             519231          0        100        1.9            15-05-2012 22:02:30 
 
'DUPLICATE/RESTORETHROUGHPUT MBYTES_SOFAR MBYTES_PER_SEC NAME 
---------------------------- ------------ -------------- -------------------------- 
DUPLICATE/RESTORE THROUGHPUT         22.3            .07 physical write total bytes 
 
'BACKUPTHROUGHPUT MBYTES_SOFAR MBYTES_PER_SEC NAME 
----------------- ------------ -------------- -------------------------- 
BACKUP THROUGHPUT         5868          50.59 physical read total bytes

Shell Script code below:

#!/bin/bash
# $Id: ora_watch.sh 24 2010-03-16 00:18:42Z cricci $
#=========================================================================+
#  Copyright (c) 2009 Christian Daniel Ricci, Sydney, Australia           |
#                          All rights reserved.                           |
#=========================================================================+
# FILENAME
#       rman_duplicate_monitor_eta.sh.sh
#
# DESCRIPTION
#       Monitor RMAN operations
#
# HISTORY
#       CR - 16-Mar-2010 - Created
#
#=========================================================================*/

while [ 1 -eq 1 ]; do

ps -ef | grep rman | grep -v grep > /dev/null
[ $? -eq 1 ] && exit 0

echo "-------- RMAN: timing information - `date` ----------"

sqlplus -s '/as sysdba' <<EOF
col opname for a30
col message for a30 wra on
col units for a15
set lin 300 pages 1000 feed off echo off

alter session set nls_date_format='dd-mm-yyyy hh24:mi:ss';

select OPNAME,
--message,
SOFAR,TOTALWORK,round((SOFAR*100/decode(TOTALWORK,0,SOFAR,TOTALWORK)),2) PCT_DONE,
--UNITS,
round(elapsed_seconds/60,1) ela_min,round(time_remaining/60,1) eta_min,
START_TIME,round(time_remaining/60,1)/60/24+sysdate finish_time
 from v\$session_longops
where
OPNAME like 'RMAN%'
and SOFAR != TOTALWORK
order by 8;

SELECT
  'DUPLICATE/RESTORE THROUGHPUT',
  round(SUM(v.value/1024/1024),1) mbytes_sofar,
  round(SUM(v.value     /1024/1024)/nvl((SELECT MIN(elapsed_seconds)
  FROM v\$session_longops
  WHERE OPNAME LIKE 'RMAN: aggregate input'
  AND SOFAR            != TOTALWORK
  AND elapsed_seconds IS NOT NULL
  ),SUM(v.value     /1024/1024)),2) mbytes_per_sec,
  n.name
FROM gv\$sesstat v,
  v\$statname n,
  gv\$session s
WHERE v.statistic#=n.statistic#
AND n.name = 'physical write total bytes'
AND v.sid = s.sid
AND v.inst_id=s.inst_id
AND s.program like 'rman@%'
GROUP BY 'DUPLICATE/RESTORE THROUGHPUT',n.name;

SELECT
  'BACKUP THROUGHPUT',
  round(SUM(v.value/1024/1024),1) mbytes_sofar,
  round(SUM(v.value     /1024/1024)/nvl((SELECT MIN(elapsed_seconds)
  FROM v\$session_longops
  WHERE OPNAME LIKE 'RMAN: aggregate output'
  AND SOFAR            != TOTALWORK
  AND elapsed_seconds IS NOT NULL
  ),SUM(v.value     /1024/1024)),2) mbytes_per_sec,
  n.name
FROM gv\$sesstat v,
  v\$statname n,
  gv\$session s
WHERE v.statistic#=n.statistic#
AND n.name = 'physical read total bytes'
AND v.sid = s.sid
AND v.inst_id=s.inst_id
AND s.program like 'rman@%'
GROUP BY 'BACKUP THROUGHPUT',n.name;

exit
EOF

sleep 60

done
===================================================================

No comments: