Description : In this blog, we are going to see the Oracle database restore point and its types with the demo.Normal Restore Point:
A normal restore point enables you to flash the database back to a restore point within the time determined by DB_FLASHBACK_RETENTION_TARGET initialization parameter setting.
A normal restore point can be dropped explicitly.
The control files stores name of the restore point and the SCN.
Guaranteed restore point:
A guaranteed restore point enables you to flash the database back to the restore point regardless of DB_FLASHBACK_RETENTION_TARGET initialization parameter setting.
Guaranteed restore point must be dropped explicitly by the user using the DROP RESTORE POINT command.
Guaranteed restore point never ages out.
Normal Restore Point Demo:Must DB in archive log mode.SQL> archive log list;
Database log mode Archive Mode
Automatic archival EnabledCheck available restore point:SQL> select name from v$restore_point;
no rows selectedCreate a normal restore point:SQL> create restore point res_test;
Restore point created.View the created restore point:SQL> select name from v$restore_point;
NAME
——————–
RES_TESTAfter the creation of the restore point creates a table.SQL> create table test as select * from dba_users;
Table created.Check the RVWR process status. In normal restore point no background process are started.
[oracle@primary ~]$ ps -ef |grep -i rvwr
oracle 16948 14963 0 09:40 pts/2 00:00:00 grep –color=auto -i rvwrFlashback the restore point:SQL> flashback database to restore point res_test;
Flashback complete.Guaranteed Restore Point Demo:Create guarantee restore point:SQL> create restore point res_test1 guarantee flashback database;
Restore point created.RVWR back ground process can be started automatically.[oracle@primary ~]$ ps -ef |grep -i rvwr
oracle 17014 1 0 09:41 ? 00:00:00 ora_rvwr_orcl
oracle 17060 14963 0 09:42 pts/2 00:00:00 grep –color=auto -i rvwr
[oracle@primary ~]$Check the flashback status:SQL> select flashback_on from v$database;
FLASHBACK_ON
——————
RESTORE POINT ONLYAutomatically create flashback logs:[oracle@primary ORCL]$ cd flashback/
[oracle@primary flashback]$ ls
o1_mf_jtotn2c3_.flb o1_mf_jtotn8d4_.flbDrop restore point the logs will be removed.SQL> drop restore point res_test1;
Restore point dropped.
[oracle@primary ~]$ cd /u01/app/oracle/fast_recovery_area/ORCL/flashback
[oracle@primary flashback]$ ls
[oracle@primary flashback]$Bounce database and Flashback database to restore point:SQL> flashback database to restore point res_test2;
Flashback complete.Reset the logs:SQL> alter database open resetlogs;
Database altered.SQL> select count(*) from test1;
COUNT(*)
———-
45 Thank you for giving your valuable time to read the above information.If you want to be updated with all our articles send us the Invitation or Follow us:Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8
Description:- In this blog, we are going to see the Oracle database incarnation using RMAN backup with the demo.
INCARNATION:- The current online redo logs are archived, the log sequence number is reset to 1, a new database incarnation is created, and the online redo logs are given a new timestamp and SCN.
Database incarnation falls into the following category:- Current, Parent, Ancestor, and Sibling:
i) Current Incarnation: The database incarnation in which the database is currently generating redo. ii) Parent Incarnation: The database incarnation from which the current incarnation branched following an OPEN RESETLOGS operation. iii) Ancestor Incarnation: The parent of the parent incarnation is an ancestor incarnation. Any parent of an ancestor incarnation is also an ancestor incarnation. iv) Sibling Incarnation: Two incarnations that share a common ancestor are sibling incarnations if neither one is an ancestor of the other.
Overall steps:-
Backup full database using RMAN
After backup create a table in the database note the SCN number.
Delete and Drop table take SCN number.
Do log switching and check incarnation status.
Bounce the database started in the mount stage.
Connect RMAN and recover the database mention the sequence number where the table record was deleted.
After the recovery is completed perform resetlogs to open the database.
Connect a database to check incarnation also check the table can be retrieved.
Shut the database and start the mount stage again.
Reset the database incarnation 2 to retrieve the table records mention the scn where the table was created.
Check record can be retrieved.
Step 1: Backup full database:-
[oracle@test ~]$ . livedb.env[oracle@test ~]$ rman target /connected to target database: LIVEDB (DBID=3038906043)
RMAN> backup database;
Starting backup at 15-SEP-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=82 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/LIVEDB/datafile/
o1_mf_system_jmz2qqys_.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/LIVEDB/datafile/
o1_mf_undotbs1_jmz2snrh_.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/LIVEDB/datafile/
o1_mf_sysaux_jmz2rvhs_.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/LIVEDB/datafile/
o1_mf_users_jmz2sovr_.dbf
channel ORA_DISK_1: starting piece 1 at 15-SEP-21
channel ORA_DISK_1: finished piece 1 at 15-SEP-21
piece handle=/u01/app/oracle/fast_recovery_area/LIVEDB/backupset/2021_09_15/
o1_mf_nnndf_TAG20210915T035943_jn28lqm2_.bkp tag=TAG20210915T035943 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06
Finished backup at 15-SEP-21Starting Control File and SPFILE Autobackup at 15-SEP-21
piece handle=/u01/app/oracle/fast_recovery_area/LIVEDB/autobackup/2021_09_15/
o1_mf_s_1083297650_jn28ntoh_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 15-SEP-21
RMAN> exit
Step 2: After backup create a table in the database note SCN number :-
[oracle@test ~]$ . livedb.env [oracle@vtest ~]$ sqlplus / as sysdba SQL> create table sample as select * from all_objects; Table created. SQL> select current_scn from v$database; CURRENT_SCN
———–———– 2146558
Step 3: Delete and Drop table take SCN number:- Delete the rows in the sample table: SQL> delete from the sample; 71297 rows deleted.
Get the scn number also, SQL> select current_scn from v$database; CURRENT_SCN
———-———– 2146578
Drop the table structure: SQL> drop table sample; Table dropped. SQL> commit; Commit complete. SQL> select current_scn from v$database; CURRENT_SCN
——————– 2146601
Step 4: Do log switching and check incarnation status:-
SQL> alter system switch logfile; System altered. Check the incarnation using v$database_incarnation: SQL> select incarnation#, resetlogs_change# from v$database_incarnation; INCARNATION# RESETLOGS_CHANGE# ———— —————– 1 1 2 1920977
Step 5: Bounce the database start in mount stage:-
SQL> startup mount ORACLE instance started. Total System Global Area 1694495520 bytes Fixed Size 8897312 bytes Variable Size 402653184 bytes Database Buffers 1275068416 bytes
Redo Buffers 7876608 bytes Database mounted.
Step 6: Connect RMAN and recover the database mention the sequence number where the table record was deleted:-
[oracle@test ~]$ rman target /
connected to target database: LIVEDB (DBID=3038906043, not open)
RMAN> run{
set until scn=2146578;
restore database;
recover database;
}
executing command: SET until clause
Starting restore at 15-SEP-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=45 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/
LIVEDB/datafile/o1_mf_system_jmz2qqys_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/
LIVEDB/datafile/o1_mf_sysaux_jmz2rvhs_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/
LIVEDB/datafile/o1_mf_undotbs1_jmz2snrh_.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/
LIVEDB/datafile/o1_mf_users_jmz2sovr_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/
LIVEDB/backupset/2021_09_15/o1_mf_nnndf_TAG20210915T035943_jn28lqm2_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/LIVEDB/
backupset/2021_09_15/o1_mf_nnndf_TAG20210915T035943_jn28lqm2_.bkp
tag=TAG20210915T035943channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:56
Finished restore at 15-SEP-21Starting recover at 15-SEP-21
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01Finished recover at 15-SEP-21
Step 7: After the recovery is completed perform resetlogs to open the database:-
RMAN> alter database open resetlogs; Statement processed RMAN> exit
Step 8 : Connect database to check incarnation also check the table can be retrieved:-
[oracle@test ~]$ sqlplus / as sysdba SQL> select incarnation#, resetlogs_change# from v$database_incarnation; INCARNATION# RESETLOGS_CHANGE# ———— —————– 1 1 2 1920977 3 2146579 The table structure is retrieved but the record can be deleted from the scn number stage. SQL> select * from the sample; no rows selected
Step 9: Shut the database and start the mount stage again:-
SQL> select name from v$tablespace;
NAME
------------------------------
SYSAUX
SYSTEM
UNDOTBS1
USERS
TEMP
TEST
6 rows selected.
SQL> alter tablespace users offline;
Tablespace altered.
SQL> exit
[oratest@oracle dbs]$ date
Wed Sep 8 22:15:37 IST 2021
Connect RMAN and backup tablespace
[oratest@oracle dbs]$ rman target/
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 8 22:16:02 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2378581000)
RMAN> restore tablespace users until time "to_date ('08-SEP-2021 22:15:37','DD-MON-YYYY:HH24:MI:SS')";
Starting restore at 08-SEP-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/TEST/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/oradata/TEST/backup/1408j583_1_1
channel ORA_DISK_1: piece handle= /u01/app/oracle/oradata/TEST/backup/1408j583_1_1 tag=TAG20210908T221323
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 08-SEP-21
[oracle@oracle ~]$ rman target/
RMAN> restore tablespace users;
Starting restore at 08-SEP-21
using channel ORA_DISK_1
skipping datafile 5; already restored to file /u01/app/oracle/oradata/TEST/datafile/users.dbf
restore not done; all files read only, offline, excluded, or already restored
Finished restore at 08-SEP-21
RMAN> recover tablespace users;
Starting recover at 08-SEP-21
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 32 is already on disk as file /u01/app/oracle/fast_recovery_area/TEST/archivelog/2021_09_02/o1_mf_1_32_jlzwlxjb_.arc
media recovery complete, elapsed time: 00:00:12
Finished recover at 08-SEP-21
RMAN> exit
Recovery Manager complete.
[oratest@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 8 22:51:07 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/TEST/system01.dbf
/u01/app/oracle/oradata/TEST/test03.dbf
/u01/app/oracle/oradata/TEST/sysaux01.dbf
/u01/app/oracle/oradata/TEST/undotbs01.dbf
/u01/app/oracle/oradata/TEST/test01.dbf
/u01/app/oracle/oradata/TEST/users01.dbf
6 rows selected.
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
[oratest@oracle ~]$ export ORACLE_SID=test
[oratest@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 8 21:25:19 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show parameter pfile;
NAME TYPE VALUE
------- ------- ------------------------------
spfile string /u01/app/oracle/product/19.0.0
/dbhome_1/dbs/spfiletest.ora
Connect RMAN and Backup the Spfile:
[oratest@oracle ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 8 21:26:38 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2378581000)
RMAN> backup spfile;
Starting backup at 08-SEP-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 08-SEP-21
channel ORA_DISK_1: finished piece 1 at 08-SEP-21
piece handle=/u01/app/oracle/oradata/TEST/backup/1208j2hb_1_1 tag=TAG20210908T212707 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-SEP-21
Starting Control File and SPFILE Autobackup at 08-SEP-21
piece handle=/u01/app/oracle/oradata/TEST/backup/c-2378581000-20210908-00 comment=NONE
Finished Control File and SPFILE Autobackup at 08-SEP-21
sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 8 21:28:32 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Move the Spfile to Backup File
[oracle@oracle ~]$ cd $ORACLE_HOME/dbs
[oracle@oracle dbs]$ ls
Spfiletest.ora inittest.ora
[oracle@oracle dbs]$ mv spfiletest.ora spfiletest.ora_bkp
[oracle@oracle dbs]$ ls
initorcl.ora Spfiletest.ora_bkp
[oratest@oracle dbs]$ rman target/
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 8 21:33:14 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> set dbid 2378581000
executing command: SET DBID
start the database in force option with nomount stage
RMAN> startup force nomount;
Oracle instance started
Total System Global Area 1543500144 bytes
Fixed Size 8896880 bytes
Variable Size 905969664 bytes
Database Buffers 620756992 bytes
Redo Buffers 7876608 bytes
Restore the spfile from Auto backup Location
RMAN> restore spfile from autobackup;
Starting restore at 08-SEP-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
recovery area destination: /u01/app/oracle/fast_recovery_area
database name (or database unique name) used for search: TEST
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/TEST/autobackup/2021_09_05/o1_mf_s_1082499783_jm9xhjjd_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20210905
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/TEST/autobackup/2021_09_05/o1_mf_s_1082499783_jm9xhjjd_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 08-SEP-21
Recovery Manager complete.
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Sep 5 22:32:18 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
TEST MOUNTED
Using alter command open the database
SQL> alter database open;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
TEST READ WRITE
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
Thank you for giving your valuable time to read the above information. If you want to be updated with all our articles send us the Invitation or Follow us: