RMAN> host 'export NLS_DATE_FORMAT="DD.MON.YYYY HH24:MI:SS"; $ORACLE_HOME/bin/rman target /';
RMAN> list backup summary completed after "sysdate-1";
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- -------------------- ------- ------- ---------- ---
8054 B F A SBT_TAPE 09.FEB.2012 16:05:48 1 1 NO TAG20120209T160539
RMAN> list backup summary completed after "sysdate-1";
alias rmanme='rman target / | tee rman_`/bin/date +\%d\%m\%y:%H:%M:%S`.log'
with logfile
oracle@apt-amd-02:~> rman
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jul 16 06:23:02 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target /
connected to target database: ORCL (DBID=1267852645)
RMAN> list backupset;
using target database control file instead of recovery catalog
specification does not match any backup in the repository
RMAN> list backup of database;
specification does not match any backup in the repository
RMAN> list backup of archivelog all;
specification does not match any backup in the repository
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
no obsolete backups found
RMAN> report obsolete redundancy = 2;
no obsolete backups found
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=54 device type=DISK
no obsolete backups found
RMAN> restore database validate;
Starting restore at 16-JUL-11
using channel ORA_DISK_1
datafile 6 will be created automatically during restore operation
datafile 7 will be created automatically during restore operation
datafile 8 will be created automatically during restore operation
datafile 9 will be created automatically during restore operation
datafile 10 will be created automatically during restore operation
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/16/2011 06:24:37
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
RMAN> report unrecoverable;
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
---- ----------------------- -----------------------------------
5 full /opt/app/oracle/oradata/orcl/example01.dbf
RMAN> report schema;
Report of database schema for database with db_unique_name ORCL
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 810 SYSTEM *** /opt/app/oracle/oradata/orcl/system01.dbf
2 830 SYSAUX *** /opt/app/oracle/oradata/orcl/sysaux01.dbf
3 325 UNDOTBS1 *** /opt/app/oracle/oradata/orcl/undotbs01.dbf
4 352 USERS *** /opt/app/oracle/oradata/orcl/users01.dbf
5 100 EXAMPLE *** /opt/app/oracle/oradata/orcl/example01.dbf
6 10 ANUJTEST *** /opt/app/oracle/oradata/orcl/anujtest.dbf
7 50 TSAPEXF *** /opt/app/oracle/oradata/orcl/tsapexf01.dbf
8 110 TSAPEXU *** /opt/app/oracle/oradata/orcl/tsapexu01.dbf
9 20 TEST *** /opt/app/oracle/oradata/orcl/test.dbf
10 50 RMAN *** /opt/app/oracle/oradata/orcl/rman.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 276 TEMP 32767 /opt/app/oracle/oradata/orcl/temp01.dbf
RMAN> crosscheck backup;
using channel ORA_DISK_1
specification does not match any backup in the repository
RMAN> delete expired backup;
using channel ORA_DISK_1
specification does not match any backup in the repository
RMAN> LIST BACKUPSET OF DATABASE;
specification does not match any backup in the repository
RMAN>
RMAN> RESTORE DATABASE VALIDATE;
Starting restore at 16-JUL-11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: reading from backup piece /aptus/oracle/data/1/Rmanbackup/databasefiles_APTDB_3jmhii8t_17523_20110716
channel ORA_DISK_1: restored backup piece 1
piece handle=/aptus/oracle/data/1/Rmanbackup/databasefiles_APTDB_3jmhii8t_17523_20110716 tag=TAG20110716T073037
channel ORA_DISK_1: validation complete, elapsed time: 00:01:06
Finished restore at 16-JUL-11
===
delete archive
RMAN> backup archive log all format '/u1/oradata/db/arch-bak';
RMAN> delete archive until time 'trunc(sysdate)';
In order to skip two tablespaces issue command in RMAN twice
RMAN> CONFIGURE EXCLUDE FOR TABLESPACE abc;
RMAN> CONFIGURE EXCLUDE FOR TABLESPACE xyz;
RMAN> SHOW EXCLUDE;
You can override this exclusion feature by explicitly issuing keyword NOEXCLUDE in order to take whole database backup.
RMAN>BACKUP DATABASE NOEXCLUDE;
disable the exclusion feature for xyz tablespace
RMAN>CONFIGURE EXCLUDE FOR TABLESPACE xyz CLEAR;
===
RMAN> restore database validate preview; - <<<<<<<<<<<<<<<<<-----------------------
RMAN> list backup of controlfile;
rman> list backup;
rman> list backup of database;
rman> list backup summary;
rman> list incarnation;
rman> list backup by file;
rman> list copy of database archivelog all;
rman> list copy of datafile 1, 2, 3;
rman> list backup of datafile 11 summary;
rman> list backup of archivelog from sequence 1234;
rman> list controlfilecopy "/u01/app/oracle/ctrl1.cpy";
rman> list backupset of datafile 1;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
15667 Full 1.88M DISK 00:00:01 06-JUL-11
BP Key: 15667 Status: AVAILABLE Compressed: YES Tag: TAG20110706T010535
Piece Name: /aptus/oracle/data/1/Rmanbackup/databasefiles_APTDB_3hmgngbu_17521_20110706
Control File Included: Ckp SCN: 127799062 Ckp time: 06-JUL-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
15670 Full 1.88M DISK 00:00:02 16-JUL-11
BP Key: 15670 Status: AVAILABLE Compressed: YES Tag: TAG20110716T073037
Piece Name: /aptus/oracle/data/1/Rmanbackup/databasefiles_APTDB_3kmhiibs_17524_20110716
Control File Included: Ckp SCN: 128194984 Ckp time: 16-JUL-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
15671 Full 1.86M DISK 00:00:01 16-JUL-11
BP Key: 15671 Status: AVAILABLE Compressed: YES Tag: TAG20110716T073219
Piece Name: /aptus/oracle/data/1/Rmanbackup/controlfile_APTDB_3lmhiic3_17525_20110716
Control File Included: Ckp SCN: 128194995 Ckp time: 16-JUL-11
==================================================
RMAN> run {
set until time to_date('04-Aug-2004 00:00:00', 'DD-MON-YYYY HH24:MI:SS');
restore database;
recover database;
}
=============================
RMAN> run {
2> set until time '27-oct-2011 12:11:00';
3> }
executing command: SET until clause
RMAN> sql "alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''";
using target database control file instead of recovery catalog
sql statement: alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''
recover database UNTIL TIME '2011-11-15:14:07:00'
The time format must be in the format YYYY-MM-DD:HH24:MM:SS irrespective of NLS_DATE_FORMAT
run {
shutdown immediate;
startup mount;
sql "alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''";
set until time '15-aug-2006 14:11:00';
restore database;
recover database;
alter database open resetlogs;}
col group# for 9999
col status for a8
col member for a40
select f.group#,
sequence#,
l.status,
member
from v$logfile f, v$log l
where f.group#=l.group#
order by group#
GROUP# SEQUENCE# STATUS MEMBER
------ ---------- -------- ----------------------------------------
4 58 INACTIVE /opt/app/oracle/oradata/orcl/redo04.log
5 59 INACTIVE /opt/app/oracle/oradata/orcl/redo05.log
6 60 CURRENT /opt/app/oracle/oradata/orcl/redo06.log
run {
shutdown immediate;
startup mount;
set until sequence 59 thread 1;
restore database;
recover database;
alter database open resetlogs;
}
UNTIL CHANGE / UNTIL SCN Recovery
* SQL> shutdown immediate;
* SQL> startup mount;
* —No restore b/c OS or other means are used to restore necessary files—
* SQL> recover database UNTIL CHANGE 309121;
* SQL> alter database open resetlogs;
* —–ALTERNATIVE in RMAN—–
run {
shutdown immediate;
startup mount;
set until scn 309121;
restore database;
recover database;
alter database open resetlogs;}
oracle@novagenesis$ rman target=/ log=anujrman.log <<<<< --- for RMAN log file
to duplicate database .. from asm file system non ASM filesystem
[oracle@rac1 dupdb]$ rman target=sys/oracle@demodb auxiliary=/
RMAN> duplicate target database to dupdb nofilenamecheck;
to restore RMAN
RMAN> restore controlfile from 'e:\backup\CTL_SP_BAK_xxxxxxxxxx-20050228-00';
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/aptus/oracle/data/1/Rmanbackup/cotrolfile%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/aptus/oracle/data/1/Rmanbackup/%d_DB_%u_%s_%p';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/aptus/oracle/product/10g/dbs/snapcf_aptdb.f'; # default
====
Listing Incarnations
A new incarnation of the database is created when you perform the open resetlogs operation. To view the list of database incarnations,
RMAN> List incarnation;
List Summary of Backups
The summary of backups include backupset key, the status, device type, completion time etc,
RMAN> List Backup Summary;
RMAN> List expired Backup of archivelog all summary;
RMAN> List Backup of tablespace Test summary;
List Backups of various files
It provides the summary of the backups available for each datafile, controlfile, archivelog file and spfile.
RMAN> List Backup By File;
f you want the detailed report on the backups, then issue the following command.
RMAN> List Backup;
It lists the all available information about the backups.
Backups used for Recovery
To list the backups used for restore and recovery,
RMAN> list recoverable backup;
Expired Backups
The list backup shows both available and expired backups. To view only the expired backups,
RMAN> List expired Backup;
RMAN> List expired Backup summary;
RMAN> List expired Backup of Archivelog all;
RMAN> List expired Backup of datafile 10;
Listing Tablespace and Datafile Backups
RMAN> List Backup of Tablespace Test;
RMAN> List Backup of Datafile 4;
Listing Archivelog Backups
RMAN> List Archivelog all;
RMAN> List Archivelog all backedup 2 times to device type sbt;
Listing Controlfile and Spfile Backups
RMAN> List Backup of Controlfile;
RMAN> List Backup of Spfile;
The above list commands displayed information about the backusets.
If you have performed Image copy backups then you must use the list copy command as shown below,
RMAN> List Copy;
RMAN> List Copy of database;
RMAN> List Copy of tablespace test;
RMAN> List Copy of archivelog all;
RMAN> List Copy of archivelog from sequence 12345;
RMAN> List Copy of archivelog from sequence 1000 until sequence 1010;
RMAN> List Copy of Controlfile;
RMAN> List Copy of Spfile;
recover database from tag="TAG20051024T1XXXXX" validate;
restore database from tag="XXXXXXXX";
RMAN> SET DBID=228033884;
RMAN> CONNECT TARGET
4. Restore the controlfile from autobackup
% rman trace recocf.log
RMAN> SET DBID=228033884;
RMAN> CONNECT TARGET
RMAN> RUN
{ SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE disk TO '/rman/V920/%F';
ALLOCATE CHANNEL d1 DEVICE TYPE disk;
RESTORE CONTROLFILE FROM AUTOBACKUP
MAXSEQ 5 # start at sequence 5 and count down (optional)
MAXDAYS 5; # start at UNTIL TIME and search back 5 days (optional)
MOUNT DATABASE;
}
5. Verify what is available for incomplete recovery.
We will recover to the highest SCN log sequence and thread. We will use the log sequence in this case.
The options are "until time", "until scn", or "until sequence".
* First we need to fine the highest sequence of each thread:
SQL> select max(sequence#) from v$archived_log where thread#=1;
MAX(SEQUENCE#)
--------------
25
SQL> select max(sequence#) from v$archived_log where thread#=2;
MAX(SEQUENCE#)
--------------
13
* Next is to find the thread with highest SCN ( NEXT_CHANGE# )
In this case the SCN is greater in thread 2 sequence 13 than in sequence 25 thread 1. So we will use thread 2. We will set sequence 14 thread 2 for RMAN 'until sequence' recovery, because RMAN stops the recovery before applying the indicated sequence. Log sequence for recovery needs always be sequence+1 to end at +1 after applying the prior sequence.
SQL> select sequence#, thread#, first_change#, next_change#
from v$archived_log
where sequence# in (13,25);
SEQUENCE# THREAD# FIRST_CHANGE# NEXT_CHANGE#
-------------------- -------------- ------------------------- -------------------------
25 1 1744432 1744802
13 2 1744429 1744805
SQL> select sequence#, thread#, first_change#, next_change#
from v$backup_redolog
where sequence# in (13,25);
SEQUENCE# THREAD# FIRST_CHANGE# NEXT_CHANGE#
-------------------- -------------- ------------------------- -------------------------
25 1 1744432 1744802
13 2 1744429 1744805
--- SET UNTIL SEQUENCE 14 THREAD 2 ----
6. Get the sentences to add TEMPFILES after opening DB.
Locally Managed Temporary Tablespaces are not restored by RESTORE command, we need to create them manually after recovery is complete.
If using LMT Temporary tablespace the controlfile will have the syntax to add the tempfile after recovery is complete. The following command will give us the create controlfile sencence:
SQL> alter database backup controlfile to trace;
Example:
# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/dev/db/rV92B_temp_01.dbf' SIZE 41943040 REUSE AUTOEXTEND OFF;
# End of tempfile additions.
#
7. Run the rman script
Since log sequence 13 thread 2 next_change# is 3 changes ahead of thread 1 sequence 25 we are using sequence 14 to stop recovery. This will restore the data files and recover them completely using the online logs.
run {
SET UNTIL SEQUENCE 14 THREAD 2;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
}
Finally add the tempfiles with sentences from step 6.
# Preview
RESTORE DATABASE PREVIEW;
RESTORE TABLESPACE users PREVIEW;
# Preview Summary
RESTORE DATABASE PREVIEW SUMMARY;
RESTORE TABLESPACE users PREVIEW SUMMARY;
RMAN> list incarnation of database aptdb ;
RMAN> LIST INCARNATION ;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 APTDB 204677159 CURRENT 1 01-JUN-11
Debug the restore session using:
RMAN trace
C:\>rman target / log=RmanLog.txt trace=rmanTrace.txt
RMAN> debug on;
RMAN> restore datafile 1;
RMAN> debug off;
RMAN> exit;
Resetting RMAN to a Previous Incarnation in NOCATALOG Mode
CONNECT TARGET / NOCATALOG
# step 1: start and mount a control file that knows about the incarnation to which
# you want to return. Refer to the RESTORE command for appropriate options.
STARTUP NOMOUNT;
RESTORE CONTROLFILE FROM AUTOBACKUP;
ALTER DATABASE MOUNT;
# step 2: obtain the primary key of old incarnation
LIST INCARNATION OF DATABASE trgt;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ------------- ------- ---------- ----------
1 2 TRGT 1334358386 PARENT 154381 OCT 30 2007 16:02:12
1 116 TRGT 1334358386 CURRENT 154877 OCT 30 2007 16:37:39
# step 3: in this example, reset database to incarnation key 2
RESET DATABASE TO INCARNATION 2;
# step 4: restore and recover the database to a point before the RESETLOGS
RESTORE DATABASE UNTIL SCN 154876;
RECOVER DATABASE UNTIL SCN 154876;
# step 5: make this incarnation the current incarnation and list incarnations:
ALTER DATABASE OPEN RESETLOGS;
LIST INCARNATION OF DATABASE trgt;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- ------- ---------- ----------
1 2 TRGT 1334358386 PARENT 154381 OCT 30 2007 16:02:12
1 116 TRGT 1334358386 PARENT 154877 OCT 30 2007 16:37:39
1 311 TRGT 1334358386 CURRENT 156234 AUG 13 2007 17:17:03
Backupset Maintenance using the configured retention policy
RMAN> list backup summary;
list backup by datafile;
list backup of database;
list backup of archivelog all;
list backup of controlfile;
Start RMAN in debug mode:
rman target debug trace=rman.trc log=rman.log
Activate sql traces
rman> set echo on;
rman> sql "alter system set max_dump_file_size=UNLIMITED";
rman> sql "alter session set events ''10046 trace name context forever, level 12''" ;
###########################
# RMAN Format Description
###########################
%a Current database activation id
%A Zero-filled activation ID
%c The copy number of the backup piece within a set of duplexed backup pieces.bMaximum value is 256
%d Database name
%D Current day of the month from the Gregorian calendar in format DD
%e Archived log sequence number
%f Absolute file number
%F Combines the DBID, day, month, year, and sequence into a unique and repeatable generated name
%h Archived redo log thread number
%I DBID
%M Month in the Gregorian calendar in the format MM
%n Database name, padded on the right with x characters to a total length of eight characters
%N Tablespace name. Only valid when backing up datafiles as image copies.
%p Piece number within the backup set. This value starts at 1 for each backup set and is incremented by 1
for each backup piece created. If a PROXY is specified, the %p variable must be included in the FORMAT
string either explicitly or implicitly within %U.
%r Resetlogs ID
%s Backup set number. This number is a counter in the control file that is incremented for each backup set.
The counter value starts at 1 and is unique for the lifetime of the control file. If you restore a backup
control file, then duplicate values can result. CREATE CONTROLFILE initializes the counter at 1.
%S Zero-filled sequence number
%t Backup set time stamp, a 4-byte value derived as the number of seconds elapsed since a fixed reference time.
The combination of %s and %t can be used to form a unique name for the backup set.
%T Year, month, and day in the Gregorian calendar in the format: YYYYMMDD
%u An 8-character name constituted by compressed representations of the backup set or image copy number and the
time the backup set or image copy was created
%U A system-generated unique filename (default). %U is different for image copies and backup pieces.
For a backup piece, %U is a shorthend for %u_%p_%c and guarantees uniqueness in generated backup filenames.
For an image copy of a datafile, %U means the following: data-D-%d_id-%I_TS-%N_FNO-%f_%u
%Y Year in this format: YYYY
%% Percent (%) character. For example, %%Y translates to the string %Y
RMAN> LIST FAILURE;
no failures found that match specification
RMAN> ADVISE FAILURE;
no failures found that match specification
RMAN> ADVISE FAILURE 101;
show COMPRESSION ALGORITHM;
CONFIGURE COMPRESSION ALGORITHM TO 'alg_name';
SQL> col ALGORITHM_NAME format a10
select * from v$rman_encryption_algorithms
ALGORITHM_ID ALGORITHM_ ALGORITHM_DESCRIPTION IS_ RES
------------ ---------- ---------------------------------------------------------------- --- ---
1 AES128 AES 128-bit key YES NO
2 AES192 AES 192-bit key NO NO
3 AES256 AES 256-bit key NO NO
-----------------------------------------------
restore database preview and validate
RMAN> restore database preview;
RMAN> restore database preview;
RMAN> restore database from tag FULL_BKP preview;
RMAN> restore datafile 1, 2 preview;
RMAN> restore archivelog all preview summary;
RMAN> restore archivelog from time 'sysdate - 1/24' preview summary;
RMAN> restore archivelog from scn 25 preview summary;
RMAN> restore database validate check logical;
RMAN> restore database validate;
RMAN> restore database from tag FULL_BKP validate;
RMAN> restore datafile 1 validate;
RMAN> restore archivelog all validate;
RMAN> restore controlfile validate;
RMAN> restore tablespace users validate;
—————————————————————
RMAN> validate backupset 999 check logical;
Use the RMAN> list backup; command to obtain the backupset key (99 above)
RMAN> validate database check logical;
RMAN> validate database;
SET DBID 669001291;
restore until time 'sysdate-3' CONTROLFILE to 'c:\temp\cfile' from autobackup;
restore until time 'sysdate-3' CONTROLFILE to 'c:\temp\cfile' from autobackup maxdays 100;
startup force nomount;
RMAN> RUN
{ SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'C:\Backup\%F';
RESTORE CONTROLFILE FROM AUTOBACKUP; }
select DBID, NAME ,STATUS from RC_DATABASE_INCARNATION;
LIST BACKUP; # lists backup sets, image copies, and proxy copies
LIST BACKUPSET; # lists only backup sets and proxy copies
LIST COPY; # lists only disk copies
LIST BACKUP BY FILE; # shows backup sets, proxy copies, and image copies
LIST COPY BY FILE; # shows only disk copies
LIST EXPIRED BACKUP BY FILE;
LIST BACKUP SUMMARY; # lists backup sets, proxy copies, and disk copies
LIST EXPIRED BACKUP SUMMARY;
# lists backups of all files in database
LIST BACKUP OF DATABASE;
# lists copy of specified datafile
LIST COPY OF DATAFILE 'ora_home/oradata/trgt/system01.dbf';
# lists specified backup set
LIST BACKUPSET 213;
# lists datafile copy
LIST DATAFILECOPY '/tmp/tools01.dbf';
# specify a backup set by tag
LIST BACKUPSET TAG 'weekly_full_db_backup';
# specify a backup or copy by device type
LIST COPY OF DATAFILE 'ora_home/oradata/trgt/system01.dbf' DEVICE TYPE sbt;
# specify a backup by directory or path
LIST BACKUP LIKE '/tmp/%';
# specify a backup or copy by a range of completion dates
LIST COPY OF DATAFILE 2 COMPLETED BETWEEN '10-DEC-2002' AND '17-DEC-2002';
# specify logs backed up at least twice to tape
LIST ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;
RMAN> list incarnation;
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 VIHAAN 1611193673 PARENT 1 18-SEP-11
2 2 VIHAAN 1611193673 CURRENT 787897 13-DEC-11
LIST EXPIRED BACKUP
RMAN> show all;
RMAN configuration parameters for database with db_unique_name VIHAAN are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_vihaan.f'; # default
contralfile autobackup location
oracle_home/dba
Piece Name: /u01/app/oracle/product/11.2.0/db_1/dbs/c-1611193673-20120120-00
rman target=sys/{password}@ldg auxiliary=/ @create_standby.rman
Useful RMAN COMMANDS
RUN
{
ALLOCATE AUXILIARY CHANNEL c1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL c2 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL c3 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL c4 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL c5 DEVICE TYPE DISK;
DUPLICATE TARGET DATABASE to ERPSAND;
}
------------------------------
restore a particular sequence of a thread
restore archivelog from sequence 73 thread 3;
------------------------------
Which datafile is in which backup piece
SQL> select handle from v$backup_piece where set_count in(select set_count from v$backup_datafile where file#=5);
------------------------------
Delete old archive logs
1. delete noprompt archivelog all backed up 1 times to device type disk
2. delete noprompt archivelog all backed up 1 times to device type disk completed before '(sysdate-0.2)';
------------------------------
catalogging a backup piece in rman
catalog backuppiece '/erpuat/orashr/pju_
or
CATALOG START WITH '/erpuat/orashr/pju_
------------------------------
backing up log sequneces
run{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/erp/ohr/bkp4cloning/ARCH_2_%
backup archivelog from logseq=75 until logseq=88 thread 2 ;
}
------------------------------
To clean rman tape config
rman> configure CHANNEL DEVICE TYPE 'SBT_TAPE' clear;
------------------------------
Restore the archive logs to production diskgroup using the following commands if not present in the ASM diskgroup or if rman backup deleted them
Rman target /
restore archivelog from sequence 17958 until sequence 17970 thread 1;
restore archivelog from sequence 16967 until sequence 16980 thread 2;
------------------------------
To check database complete backup.
list backup of database summary completed between '15-JAN-2009' and '16-JAN-2009';
------------------------------
to check archive log backup
list backup of archivelog time between "to_date('16-JAN-2009 00:00:00','DD-MON-YYYY HH24:MI:SS')" and "to_date('16-JAN-2009 00:00:00','DD-MON-YYYY HH24:MI:SS')";
------------------------------
To monitor the Rman progress
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 ;
------------------------------
Few Rman commands
copy archivelog '+ARCHLOGS/SPPWP_EWDC/
registering logfile in dr database thru sqlplus
SQL> alter database register logfile '/spdb/data/arch/sppw/thread_
Database altered.
------------------------------
Few Rman commands
Restore controlfile:
restore controlfile from '/u02/oraback/iiss/ARCH.iiss1.
------------------------------
To restore individual archived logs from rman backups to a specified directory
RMAN> run
{
#optional line to override default location for a restore
set archivelog destination to "/spdb/data/backup/psdrp1";
restore archivelog from logseq=101837 until logseq=101839;
}
------------------------------
Clean archivelogs
delete force archivelog all completed before '(sysdate-100)';
------------------------------
List database backups
list backup of database completed after '(SYSDATE-.5)';
list backup summary completed after '(SYSDATE-.5)';
list backupset 20459 ;
list archivelog all;
delete noprompt expired archivelog all ;
crosscheck backup ;
delete noprompt obsolete;
backup archivelog all delete input ;
list archivelog all;
list copy of archivelog until time 'SYSDATE-10' ;
list copy of archivelog from time 'SYSDATE-10'
list copy of archivelog from time 'SYSDATE-10′ until time 'SYSDATE-2';
list copy of archivelog from sequence 1000 ;
list copy of archivelog until sequence 1500 ;
list copy of archivelog from sequence 1000 until sequence 1500 ;
-- Archivelog Delete Commands
delete archivelog all;
delete archivelog until time 'SYSDATE-10' ;
delete archivelog from time 'SYSDATE-10';
delete archivelog from time 'SYSDATE-10' until time 'SYSDATE-2';
delete archivelog from sequence 1000 ;
delete archivelog until sequence 1500 ;
delete archivelog from sequence 1000 until sequence 1500 ;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300;
DELETE NOPROMPT ARCHIVELOG ALL;
delete noprompt expired archivelog all;
-- Deleting all backups:
DELETE BACKUP;
-- noprompt statement for do not yes-no question.
delete noprompt archivelog until time 'SYSDATE-10' ;
-- Deleting Image copy backup:
DELETE COPY;
-- Deleting obsolete backups older than 3 days:
delete obsolete recovery window of 3 days;
-- Deleting expired backup
delete expired backup;
-- Checking Archive log files with crosscheck:
crosscheck archivelog all;
-- Checking whole backup with crosscheck:
crosscheck backup;
-- Checking image copy backup with crosscheck:
crosscheck copy;
-- Checking tagged backup with crosscheck:
crosscheck backuppiece tag = 'nightly_backup';
-- Showing Backup Preview (In which objects are listed in):
restore database preview;
restore tablespace users preview;
-- Verification whole backup:
backup validate;
-- Verification archive log files backup:
backup validate database archivelog all;
-- Verification whole database restore:
restore database validate;
-- Verification control file restore:
restore controlfile validate;
-- To debug and trace RMAN backup
$rman target=/ debug=all trace=rman.trc
-- Create the backup log file
$export NLS_DATE_FORMAT=’dd.mm.yyyy hh24:mi:ss’;
$rman target=/ log=rman.log
-- then confirm this
report need backup;
convert tablespace tbs_2 format '/tmp/tbs_2_%U.df';
For before 10 min RMAN recovery
set until time "SYSDATE -10/24/60" ;
RMAN block recovery & ORA-600
http://oraclehandson.wordpress.com/2011/04/01/rman-block-recovery-ora-600/Recover a database with JUST the datafiles?
rman backup script
run {
allocate channel dev0 type disk format '/u02/DISK_BACKUP/%d_%t_%s_%p.bkp';
allocate channel dev1 type disk format '/u02/DISK_BACKUP/%d_%t_%s_%p.bkp';
allocate channel dev2 type disk format '/u02/DISK_BACKUP/%d_%t_%s_%p.bkp';
allocate channel dev3 type disk format '/u02/DISK_BACKUP/%d_%t_%s_%p.bkp';
backup
incremental level 0
skip inaccessible
tag DiskFull_Oracle_Backup
filesperset 1
database
;
sql 'alter system archive log current';
backup
filesperset 1
format '/u02/DISK_BACKUP/A_%d_%u_%s_%T'
archivelog all
;
backup
filesperset 1
format '/u02/DISK_BACKUP/%d_%t_%s_%p.cf'
current controlfile
;
backup spfile;
}
run { crosscheck backupset of database; crosscheck backupset of controlfile; crosscheck backupset of archivelog all; crosscheck backup; delete noprompt expired backup; delete force noprompt obsolete; delete expired archivelog all; delete noprompt obsolete; delete noprompt obsolete orphan; crosscheck archivelog all; delete expired archivelog all; CROSSCHECK COPY OF CONTROLFILE; } export NLS_DATE_FORMAT='DD-MON-YY HH24:MI:SS'
CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/Rman/%F'; run { allocate channel dev0 type disk format '/u01/app/Rman/%d_%t_%s_%p.bkp'; backup incremental level 0 skip inaccessible tag DiskFull_Oracle_Backup filesperset 1 database ; sql 'alter system archive log current'; backup filesperset 1 format '/u01/app/Rman/A_%d_%u_%s_%T' archivelog all delete input ; backup filesperset 1 format '/u01/app/Rman/%d_%t_%s_%p.cf' current controlfile ; sql 'alter system archive log current'; backup filesperset 1 format '/u01/app/Rman/A_%d_%u_%s_%T' archivelog all delete input ; backup spfile format '/u01/app/Rman/spfile_%d_%s_%T.bak' tag 'spfile backup'; }
http://anuj-singh.blogspot.com/2016/09/
http://anuj-singh.blogspot.com/2021/10/rman-restore-database.html
run
{
Shutdown Immediate
Startup Mount
Set Until Sequence 15 Thread 1;
#set until scn 42773496;
#set until time "to_date('21-OCT-2020 14:45:00','DD-MON-YYYY HH24:MI:SS')";
Restore Database;
Recover Database;
Alter Database Open Resetlogs;
}
====
as per metalink RMAN: RAC Backup, Restore and Recovery using RMAN (Doc ID 243760.1)
RMAN: RAC Backup and Recovery using RMAN [ID 243760.1] select thread#,max(sequence#) sequence# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# group by thread# ; THREAD# SEQUENCE# ---------- ---------- 1 981393 2 744280 set numf 99999999999999 select sequence#, thread#, first_change#, next_change# ,COMPLETION_TIME from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# and sequence# in (981393,744280)
; set numf 99999999999999 select sequence#, thread#, first_change#, next_change# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# and sequence# in (981393,744280) ; SEQUENCE# THREAD# FIRST_CHANGE# NEXT_CHANGE# --------------- --------------- --------------- --------------- 981393 1 10540998662 10541024661 744280 2 10541014332 10541024657 * In a RAC environment, use the lower to ensure we have the redo required from threads select sequence#, thread#, first_change#, next_change# from v$backup_redolog where 1=1 and sequence# in (981393,744280); SEQUENCE# THREAD# FIRST_CHANGE# NEXT_CHANGE# --------------- --------------- --------------- --------------- 981393 1 10540998662 10541024661 744280 2 10541014332 10541024657 * In a RAC environment, use the lower to ensure we have the redo required from threads for sequnce no 744280+1 The options are "until time", "until scn", or "until sequence".
to create restore script
for RAC
define oldname='ibrac' define newname='xbrac' set pages 0 head off feed off veri off lines 500 pages 2000 echo off termout off trimspool on column cmd format a140 spool restore_recover_&&newname\.rman select 'RUN '||CHR(10)||'{' cmd from dual union all --Rename the datafiles select 'SET NEWNAME FOR DATAFILE '||file#||' TO '''||NNAME||''';' cmd from (SELECT FILE# ,NAME,replace(replace(name,upper('&&oldname'),upper('&&newname')),lower('&&oldname'),lower('&&newname')) NNAME FROM V$DATAFILE) df union all --Rename the online redo logs select 'SQL "ALTER DATABASE RENAME FILE '''''||MEMBER||''''' TO '||chr(10)||' '''''||replace(replace(member,upper('&&oldname'),upper('&&newname')),lower('&&oldname'),lower('&&newname'))||''''' ";' cmd from (SELECT GROUP#,MEMBER FROM V$LOGFILE) union all --Do a SET UNTIL to prevent recovery of the online logs select 'SET UNTIL SCN '||MINSCN||';' cmd from (select (min(next_change# )+1) MINSCN from (select thread#,sequence#, first_change#, next_change# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# and (thread#,sequence#) in (select thread#,max(sequence#) sequence# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# group by thread# ) ) ) union all --restore the database and switch the datafile names select 'RESTORE DATABASE CHECK READONLY;' cmd from dual union all select 'SWITCH DATAFILE ALL;' cmd from dual union all --recover the database select 'RECOVER DATABASE DELETE ARCHIVELOG;' from dual union all select '}'||CHR(10)||'EXIT' from dual /
select sequence#, thread#, first_change#, next_change# from v$backup_redolog where 1=1 and sequence# in (981393,744280);
--with scn no !!! set linesize 200 heading off feedback off col file_name format a100 col "Query For RMAN Restoration" for a70 select 'run {' "Query For RMAN Restoration" from dual union all select 'set newname for datafile ' ||FILE#|| ' to '||'''/u01/datafile/'|| substr(name,instr(name,'/',-1)+1, instr(substr(name,instr(name,'/',-1)+1),'.')-1 ) ||'.dbf'' ;' file_name from v$datafile union all select 'set until scn ' ||(min(next_change# )+1) ||';' from (select thread#,sequence#, first_change#, next_change# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# and (thread#,sequence#) in (select thread#,max(sequence#) sequence# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# group by thread# ) ) union all select 'restore database;' from dual union all select 'switch datafile all;' from dual union all select 'recover database;' from dual union all select '} ' from dual ; run { set newname for datafile 1 to '/u01/datafile/system01.dbf' ; set newname for datafile 2 to '/u01/datafile/apex_data01.dbf' ; set newname for datafile 3 to '/u01/datafile/sysaux01.dbf' ; set newname for datafile 4 to '/u01/datafile/undotbs01.dbf' ; set newname for datafile 5 to '/u01/datafile/undotbs02.dbf' ; set newname for datafile 7 to '/u01/datafile/users01.dbf' ; set newname for datafile 8 to '/u01/datafile/test_data01.dbf' ; set newname for datafile 9 to '/u01/datafile/test_data_ind_01.dbf' ; set newname for datafile 10 to '/u01/datafile/lobtest.dbf' ; set newname for datafile 11 to '/u01/datafile/test_uniform.dbf' ; set newname for datafile 12 to '/u01/datafile/test.dbf' ; set newname for datafile 13 to '/u01/datafile/test1.dbf' ; set newname for datafile 14 to '/u01/datafile/test1.dbf' ; set newname for datafile 15 to '/u01/datafile/bigtabs.dbf' ; set newname for datafile 16 to '/u01/datafile/test_data02.dbf' ; set until scn 2773770359; restore database; switch datafile all; recover database; } ---with Sequence c set linesize 200 heading off feedback off col file_name format a100 col "Query For RMAN Restoration" for a70 select 'run {' "Query For RMAN Restoration" from dual union all select 'set newname for datafile ' ||FILE#|| ' to '||'''/u01/datafile/'|| substr(name,instr(name,'/',-1)+1, instr(substr(name,instr(name,'/',-1)+1),'.')-1 ) ||'.dbf'' ;' file_name from v$datafile union all select 'Set Until Sequence '||(sequence# +1) || ' ' ||'Thread '||thread# ||';' --, next_change# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# and next_change# in (select min(next_change# ) from (select thread#,sequence#, first_change#, next_change# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# and (thread#,sequence#) in (select thread#,max(sequence#) sequence# from v$archived_log L, v$database D where L.resetlogs_change# = D.resetlogs_change# group by thread# ) ) ) union all select 'restore database;' from dual union all select 'switch datafile all;' from dual union all select 'recover database;' from dual union all select '} ' from dual ; run { set newname for datafile 1 to '/u01/datafile/system01.dbf' ; set newname for datafile 2 to '/u01/datafile/apex_data01.dbf' ; set newname for datafile 3 to '/u01/datafile/sysaux01.dbf' ; set newname for datafile 4 to '/u01/datafile/undotbs01.dbf' ; set newname for datafile 5 to '/u01/datafile/undotbs02.dbf' ; set newname for datafile 7 to '/u01/datafile/users01.dbf' ; set newname for datafile 8 to '/u01/datafile/test_data01.dbf' ; set newname for datafile 9 to '/u01/datafile/test_data_ind_01.dbf' ; set newname for datafile 10 to '/u01/datafile/lobtest.dbf' ; set newname for datafile 11 to '/u01/datafile/test_uniform.dbf' ; set newname for datafile 12 to '/u01/datafile/test.dbf' ; set newname for datafile 13 to '/u01/datafile/test1.dbf' ; set newname for datafile 14 to '/u01/datafile/test1.dbf' ; set newname for datafile 15 to '/u01/datafile/bigtabs.dbf' ; set newname for datafile 16 to '/u01/datafile/test_data02.dbf' ; Set Until Sequence 10 Thread 1; restore database; switch datafile all; recover database; }
allocate channel from different nodes
$rman target /
run {
allocate channel d0_1 device type disk maxopenfiles 32 connect 'sys/sys@//ibrac01.anuj.net:1521/ibrac' ;
allocate channel d0_2 device type disk maxopenfiles 32 connect 'sys/sys@//ibrac02.anuj.net:1521/ibrac' ;
DELETE EXPIRED ARCHIVELOG ALL;
release channel d0_1;
release channel d0_2;
}
using target database control file instead of recovery catalog
allocated channel: d0_1
channel d0_1: SID=1836 instance=ibrac1 device type=DISK
allocated channel: d0_2
channel d0_2: SID=1346 instance=ibrac2 device type=DISK
specification does not match any archived log in the repository
released channel: d0_1
released channel: d0_2
validate
export NLS_DATE_FORMAT='dd-mm-yyyy hh24:mi:ss' ; RUN { set until time "to_date('28-AUG-2023 01:30:00','DD-MON-YYYY HH24:MI:SS')"; restore spfile validate; restore controlfile validate; restore archivelog from time 'sysdate-23/24' validate; }
RMAN> run { set until sequence 120;
restore database root ; ------------------------->CDB$ROOT
restore database "PDB$SEED"; -------------------------------->PDB$SEED is required
restore database PDB1; } ------------------------------->PDB needing to restore
OR
RMAN>run { Set until sequence 120 ;
restore database root database "PDB$SEED" database PDB1; }
If directory structure on test server is different than the target/source database, 'SET NEWNAME' will be needed:
RMAN> report schema ;
This would show the file number associated with CDB$ROOT/PDB$SEED/PDB1.
Use 'set newname for datafile <fileno> to <new path>' to specify a new path for the datafiles.
RMAN> run { set newname for datafile <fileno> to 'system.dbf' ;
set newname for datafile <fileno> to 'system.dbf' ;
......
restore database root; ------------------------->CDB$ROOT
restore database "PDB$SEED"; -------------------------------->PDB$SEED is required
restore database PDB1; ------------------------------->PDB we want to restore
switch datafile all; }
================
{
set controlfile autobackup format for device type disk to '/rmanbackup/oradata/uknppp/cf_%F';
restore spfile from autobackup;
}
restore until time 'sysdate-1' CONTROLFILE to '/u02/oradata/20130218_control01.ctl' from autobackup;
restore until time "to_date('2013-02-18:12:01','yyyy-mm-dd:hh24:mi')" CONTROLFILE to '/u02/oradata/20130218_control01.ctl' from autobackup;
RUN {
ALLOCATE CHANNEL channel0 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=/opt/xx/xxamPluginforOracleRMAN/libOracleRMANPlugin.so';
RESTORE until time 'sysdate-1' CONTROLFILE FROM AUTOBACKUP maxdays 30;
}
run
{
set until time "to_date('2013-02-18:12:01','yyyy-mm-dd:hh24:mi')";
restore controlfile from autobackup preview;
}
rman> shutdown;
rman> startup force nomount;
rman> run
{
set controlfile autobackup format for device type disk to '/rmanbackup/oradata/uknppp/cf_%F';
restore controlfile from autobackup;
}
RUN {
ALLOCATE CHANNEL channel0 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=/opt/veeam/VeeamPluginforOracleRMAN/libOracleRMANPlugin.so';
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO '%F_RMAN_AUTOBACKUP.vab';
RESTORE controlfile FROM 'c-4097408439-20200410-00_RMAN_AUTOBACKUP.vab';
}
restore until time 'sysdate-1' CONTROLFILE to '/u02/oradata/20130218_control01.ctl' from autobackup maxdays 31;
ww
RMAN> restore until time 'sysdate-1/24' CONTROLFILE to '/u01/app/control01-1205.ctl' from '/u01/app/Rman/c-2798080093-20240511-06';
Starting restore at 12-MAY-2024 15:16:21
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 12-MAY-2024 15:16:23
RMAN>
BACKUP ARCHIVELOG SEQUENCE 30 DELETE INPUT;
BACKUP ARCHIVELOG SEQUENCE BETWEEN 31 AND 40 THREAD 1 DELETE INPUT;
CROSSCHECK ARCHIVELOG FROM SEQUENCE 0 THREAD 1;
RESTORE ARCHIVELOG SCN BETWEEN 94097 AND 106245;
backup device type disk format '/u03/backup/%U' database plus archivelog;
backup device type disk format '/u03/backup/ctrlf_%U' current controlfile;
restore controlfile from '/u03/backup/ctrlf_'; — where is the unique string generated by %U.
restore until time 'sysdate-3' CONTROLFILE to 'c:tempcfile' from autobackup;
restore until time 'sysdate-3' SPFILE to 'c:tempSPFILE' from autobackup maxdays 100;
recover database skip forever tablespace PDB2:SYSTEM,PDB2:USER,PDB2:SYSAUX,..... ; }
[oracle@<NODE>]$ rman target sys/<PASSWORD>@<TNS_ALIAS> auxiliary sys/<PASSWORD>@<TNS_ALIAS>| tee /tmp/rmanDUPLICATE.log
Restore the spfile and controlfile
run {
set controlfile autobackup format for device type disk to '\<path>\%F';
restore spfile from autobackup;
startup force nomount ; # to read parameters from restored spfile
restore controlfile from autobackup;
alter database mount ;
}
RACTEST=
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = yes)
(FAILOVER = on)
(ADDRESS = (PROTOCOL = TCP)(HOST = <node1>)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = <node2>)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = <node3>)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RACTEST)
)
)
RMAN connect:
rman target <username>/<password>@RACTEST
The username and password are for a user with SYSDBA privileges.
RMAN channel configuration:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
SELECT NAME, THREAD#, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE#
FROM V$ARCHIVED_LOG
WHERE 556890767466 >= FIRST_CHANGE#
SELECT LF.MEMBER, LF.GROUP#, L.THREAD#, L.SEQUENCE#, L.STATUS, L.FIRST_CHANGE#, L.NEXT_CHANGE#
FROM V$LOG L, V$LOGFILE LF
WHERE LF.GROUP# = L.GROUP#
AND 556890767466 >= L.FIRST_CHANGE#
oracle will pick the information from SMON_SCN_TIME table.
SCN that is greater than the MAX SCN that is available in SMON_SCN_TIME table, Oracle will get the results from the SGA.
So, as long as your SCN is between the range of the below o/p, you will get the results successfully or else it will fail with ORA- errors.
SELECT * FROM (SELECT MIN(SCN) FROM SMON_SCN_TIME), (SELECT TO_CHAR(CURRENT_SCN) FROM V$DATABASE);
7 comments:
Note.462978.1 Rman backup retention policy
Note.351455.1 Oracle Suggested Strategy & Backup Retention
NOTE:388422.1 Top 10 Backup and Recovery best practices
Note.73431.1 RMAN Compatibility Matrix
Note.305796.1 RMAN and Flash Recovery Area
Note.372996.1 Using RMAN to Restore and Recover a Database When the Repository and Spfile/Init.ora Files Are Also Lost
Note.463875.1 Frequently asked questions on Rman backup retention policy
Note.467969.1 How To Configure RMAN Recovery Catalog Using Enterprise Manager DB ConsolE
Note.415579.1 HowTo Restore RMAN Disk backups of RAC Database to Single Instance On Another Node
Useful metalink notes
RMAN Backup Fails With RMAN-03009 ORA-01858 ORA-01861 [ID 744047.1]
Query using TO_DATE TO_CHAR failing with ORA-01858 or ORA-01843 [ID 790098.1]
The Priority of NLS Parameters Explained (Where To Define NLS Parameters) [ID 241047.1]
OERR: ORA 1858 "a non-numeric character was found where a numeric was expected" [ID 19182.1]
How To Set a NLS Session Parameter At Database Or Schema Level For All Connections? [ID 251044.1]
How to check syntax of rman commands ?
rman CHECKSYNTAX @'/anuj/backup_db.cmd'
$export NLS_DATE_FORMAT="DD-MON-RRRR HH24:MI:SS"
$rman target / debug all trace=restore.trc log=restore.log
nohup rman target / cmdfile=/home/oracle/hotback.rcv log=/home/oracle/hotback1.log &
for debug
rman target catalog debug all trace=rman.trc log=rman.log
rman> set echo on
http://anuj-singh.blogspot.com/2016/09/rman-create-set-newname-script.html?m=1
Post a Comment