Saturday 25 July 2015

Longops - RMAN

SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK,ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE", TIME_REMAINING/60
Remaining_mins FROM V$SESSION_LONGOPS WHERE OPNAME LIKE 'RMAN%' AND OPNAME NOT LIKE '%aggregate%' AND TOTALWORK != 0 AND SOFAR <> TOTALWORK;

More
----
List the most recent Level 0 backups

Here,
incremental level 0 backups which runs
on Sunday using "backup as compressed backupset incremental level 0 ...."
We have incremental level 1 backups which runs
everyday other than Sunday using "backup as compressed backupset incremental level 1 database...."

select BACKUP_TYPE,INCREMENTAL_LEVEL,START_TIME,COMPLETION_TIME from v$backup_set
where START_TIME > sysdate -4 and BACKUP_TYPE='L';

B INCREMENTAL_LEVEL START_TIME        COMPLETION_TIME
- ----------------- ----------------- -----------------
D                 0 28-AUG-2012 04:30 28-AUG-2012 04:33
D                 0 28-AUG-2012 04:30 28-AUG-2012 04:33
I                 1 29-AUG-2012 04:30 29-AUG-2012 04:33
I                 1 29-AUG-2012 04:30 29-AUG-2012 04:35
I                 1 30-AUG-2012 04:30 30-AUG-2012 04:33
I                 1 30-AUG-2012 04:30 30-AUG-2012 04:35
I                 1 31-AUG-2012 04:30 31-AUG-2012 04:33
I                 1 31-AUG-2012 04:30 31-AUG-2012 04:35
D                   31-AUG-2012 04:35 31-AUG-2012 04:35
D                   31-AUG-2012 06:30 31-AUG-2012 06:30
D                   31-AUG-2012 08:30 31-AUG-2012 08:30

As per Oracle documentation V$BACKUP_SET,BACKUP_TYPE holds
"BACKUP_TYPE VARCHAR2(1) Type of files that are in this backup. If the
backup contains archived redo logs, the value is L. If this is a datafile
full
backup, the value is D. If this is an incremental backup, the value is I."
"INCREMENTAL_LEVEL NUMBER Location where this backup set fits into
the database's backup strategy. Set to zero for full datafile backups,
nonzero for incremental datafile backups, and NULL for archivelog
backups."
So the above query shows an entry with "D" which means a full datafile
backup did run today, but you can see INCREMENTAL_LEVEL is null which
means it is not a full datafile backup.

SELECT DISTINCT TO_CHAR((b.CHECKPOINT_TIME), &#39;YYYY-MM-DD HH:MI.SS&#39;) t
FROM v$backup_datafile b, v$tablespace ts, v$datafile f
WHERE b.incremental_level = 0
  AND INCLUDED_IN_DATABASE_BACKUP=&#39;YES&#39;
  AND f.file#=b.file#
  AND f.ts#=ts.ts#
GROUP BY b.checkpoint_time
ORDER BY 1;

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time      #Pieces #Copies Compressed Tag
------- -- -- - ----------- -------------------- ------- ------- ---------- ---

If you look at LV column, A=archivelog, 0=incremental level #, F=file backup.

RMAN> list backup by file tag <tag_name>;

Managing and Monitoring RMAN Backups

LIST

RMAN> list backup; // backup sets
RMAN> list copy; // image copies
RMAN> list backup of database; // whole database backup sets, full or incremental
RMAN> list backup of datafile 1;
RMAN> list backup of tablespace users;
RMAN> list backup of archivelog all;
RMAN> list copy of archivelog from time=’sysdate – 2';
RMAN> list backup of archivelog from sequence 1000 until sequence 1050;
REPORT

RMAN> report schema; // “schema” is confusing. this just shows datafiles and has nothing to do with user objects.
RMAN> report need backup;
RMAN> report need backup days 3;
RMAN> report need backup redundancy 3;
RMAN> report obsolete;
RMAN> report obsolete redundancy 2; // shows backups that are older than two others
DELETE

RMAN> delete obsolete;
RMAN> delete obsolete redundancy 2; // delete backups that are older than two others
Views & Tables

These views and data are contained in the control file only (not recovery catalog).
V$BLOCK_CHANGE_TRACKING – to monitor block change tracking
V$BACKUP_FILES
V$BACKUP_SET
V$BACKUP_PIECE
V$BACKUP_REDOLOG – each archived log that has been backed up
V$BACKUP_SPFILE – each spfile that has been backed up
V$BACKUP_DEVICE – names of sbt devices
V$RMAN_CONFIGURATION
Parameters

DB_CREATE_FILE_DEST – default location for the change tracking file.

level 0 incremental backup    the base for subsequent incremental backups, copies all blocks containing data.

You can create a level 0 database backup as backup sets or image copies.
level 1 cumulative incremental backup    backs up all blocks changed after the
most recent incremental backup at level 0
level 1 differential incremental backup    backs up all blocks changed after the most recent incremental backup at

level 1 or 0 - Incremental backups are differential by default.
Block Change Tracking    The block change tracking feature for incremental backups improves backup
performance by recording changed blocks for each datafile. - a small bitmap file.

An example is shown below where we are checking the validity of a database backup for a database which has a

weekly level 0 backup. Note that the RESTORE DATABASE VALIDATE command will cause RMAN to check for the last level

0 backup which has been performed in this case on the 15th of November.

RMAN> restore database validate;

Starting restore at 20-NOV-09
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1

channel ORA_SBT_TAPE_1: starting validation of datafile backup set
channel ORA_SBT_TAPE_1: reading from backup piece vnkud0k5_1_1
channel ORA_SBT_TAPE_1: piece handle=vnkud0k5_1_1 tag=TAG20091115T060908
channel ORA_SBT_TAPE_1: restored backup piece 1
channel ORA_SBT_TAPE_1: validation complete, elapsed time: 00:14:15
Finished restore at 20-NOV-09

RMAN> list backup of database tag TAG20091115T060908;

List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
3054 Incr 0 15.59G SBT_TAPE 00:39:00 15-NOV-09
BP Key: 3054 Status: AVAILABLE Compressed: NO Tag: TAG20091115T060908
Handle: vnkud0k5_1_1 Media:
List of Datafiles in backup set 3054
File LV Type Ckp SCN Ckp Time Name
—- — —- ———- ——— —-
1 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/system01.dbf
2 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/undotbs01.dbf
3 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/sysaux01.dbf
4 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/users01.dbf
5 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/mgmt.dbf
6 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/mgmt_ecm_depot1.dbf
7 0 Incr 23674579905 15-NOV-09 /u04/oradata/emrep/patrol01.dbf

No comments:

Post a Comment