Tuesday, September 7, 2021

LEVEL 0 and LEVEl 1 backup recovery using RMAN

 

LEVEL 0 and LEVEl 1 backup recovery using RMAN

 

Connect rman and take level 0 backup

 

 [oracle@vignesh ~]$ rman target/

 

Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 8 04:38:18 2021

Version 19.3.0.0.0

 

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: LIVEDB (DBID=3038400691)

 

RMAN> backup incremental level 0 database plus archivelog;

 

 

Starting backup at 08-SEP-21

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=34 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=5 RECID=1 STAMP=1082689816

input archived log thread=1 sequence=6 RECID=2 STAMP=1082689893

input archived log thread=1 sequence=7 RECID=3 STAMP=1082690477

input archived log thread=1 sequence=8 RECID=4 STAMP=1082690478

input archived log thread=1 sequence=9 RECID=5 STAMP=1082690480

input archived log thread=1 sequence=10 RECID=6 STAMP=1082690866

input archived log thread=1 sequence=11 RECID=7 STAMP=1082690927

input archived log thread=1 sequence=12 RECID=8 STAMP=1082691628

input archived log thread=1 sequence=13 RECID=9 STAMP=1082692404

input archived log thread=1 sequence=14 RECID=10 STAMP=1082692477

input archived log thread=1 sequence=15 RECID=11 STAMP=1082692656

input archived log thread=1 sequence=16 RECID=12 STAMP=1082695103

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/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_annnn_TAG20210908T043825_jmhw79d8_.bkp tag=TAG20210908T043825 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15

Finished backup at 08-SEP-21

 

Starting backup at 08-SEP-21

using channel ORA_DISK_1

channel ORA_DISK_1: starting incremental level 0 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_jmho76m8_.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_sysaux_jmho8n57_.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_undotbs1_jmho9f8x_.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_users_jmho9gcd_.dbf

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/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_nnnd0_TAG20210908T043841_jmhw7s4x_.bkp tag=TAG20210908T043841 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55

Finished backup at 08-SEP-21

 

Starting backup at 08-SEP-21

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=17 RECID=13 STAMP=1082695177

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/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_annnn_TAG20210908T043937_jmhw9kdv_.bkp tag=TAG20210908T043937 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/fast_recovery_area/LIVEDB/autobackup/2021_09_08/o1_mf_s_1082695178_jmhw9mmw_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 08-SEP-21

 

Check backup summary and note the level 0 backup TAG

 

RMAN> list backup of database summary;

 

 

List of Backups

===============

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

7       B  F  A DISK        08-SEP-21       1       1       NO         TAG20210908T032750

11      B  F  A DISK        08-SEP-21       1       1       NO         TAG20210908T035340

15      B  0  A DISK        08-SEP-21       1       1       NO         TAG20210908T043841

 

RMAN> exit

 

Once level 0 completed create a user and table insert the record for the purpose of level 1 backup

 

Recovery Manager complete.

[oracle@vignesh ~]$ export ORACLE_SID=livedb

[oracle@vignesh ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 8 04:42:05 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> create user ogr identified by ogr;

 

User created.

 

SQL> grant connect, resource, create session to ogr;

 

Grant succeeded.

 

SQL> alter user ogr default tablespace users quota unlimited on users;

 

User altered.

 

SQL> conn ogr/ogr

Connected.

SQL>  insert into test values(1,'one');

 

1 row created.

 

SQL> insert into test values(2,'Two');

 

1 row created.

 

SQL> insert into test values(3,'Three');

 

1 row created.

 

SQL> insert into test values(4,'Four');

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

Connect rman and take level 1 backup

 

 [oracle@vignesh ~]$ rman target /

 

Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 8 04:44:07 2021

Version 19.3.0.0.0

 

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: LIVEDB (DBID=3038400691)

 

RMAN> backup incremental level 1 database plus archivelog;

 

 

Starting backup at 08-SEP-21

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=70 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=6 RECID=2 STAMP=1082689893

input archived log thread=1 sequence=7 RECID=3 STAMP=1082690477

input archived log thread=1 sequence=8 RECID=4 STAMP=1082690478

input archived log thread=1 sequence=9 RECID=5 STAMP=1082690480

input archived log thread=1 sequence=10 RECID=6 STAMP=1082690866

input archived log thread=1 sequence=11 RECID=7 STAMP=1082690927

input archived log thread=1 sequence=12 RECID=8 STAMP=1082691628

input archived log thread=1 sequence=13 RECID=9 STAMP=1082692404

input archived log thread=1 sequence=14 RECID=10 STAMP=1082692477

input archived log thread=1 sequence=15 RECID=11 STAMP=1082692656

input archived log thread=1 sequence=16 RECID=12 STAMP=1082695103

input archived log thread=1 sequence=17 RECID=13 STAMP=1082695177

input archived log thread=1 sequence=18 RECID=14 STAMP=1082695469

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/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_annnn_TAG20210908T044430_jmhwlp8k_.bkp tag=TAG20210908T044430 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 08-SEP-21

 

Starting backup at 08-SEP-21

using channel ORA_DISK_1

channel ORA_DISK_1: starting incremental level 1 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_jmho76m8_.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_sysaux_jmho8n57_.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_undotbs1_jmho9f8x_.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_users_jmho9gcd_.dbf

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/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_nnnd1_TAG20210908T044433_jmhwlskb_.bkp tag=TAG20210908T044433 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

Finished backup at 08-SEP-21

 

Starting backup at 08-SEP-21

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=19 RECID=15 STAMP=1082695498

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/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_annnn_TAG20210908T044458_jmhwmlq5_.bkp tag=TAG20210908T044458 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/fast_recovery_area/LIVEDB/autobackup/2021_09_08/o1_mf_s_1082695499_jmhwmn2d_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 08-SEP-21

 

List the backup summary to get level 1 TAG

 

RMAN> list backup of database summary;

 

 

List of Backups

===============

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

7       B  F  A DISK        08-SEP-21       1       1       NO         TAG20210908T032750

11      B  F  A DISK        08-SEP-21       1       1       NO         TAG20210908T035340

15      B  0  A DISK        08-SEP-21       1       1       NO         TAG20210908T043841

19      B  1  A DISK        08-SEP-21       1       1       NO         TAG20210908T044433

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@vignesh ~]$ sqlplus / as sysdba

 

Check datafile location

 

SQL> select name from v$datafile;

 

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_system_jmho76m8_.dbf

/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_sysaux_jmho8n57_.dbf

/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_undotbs1_jmho9f8x_.dbf

/u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_users_jmho9gcd_.dbf

 

Remove datafiles for testing purpose

 

 [oracle@vignesh ~]$ cd /u01/app/oracle/oradata/LIVEDB/datafile/

[oracle@vignesh datafile]$ ls

o1_mf_sysaux_jmho8n57_.dbf  o1_mf_system_jmho76m8_.dbf  o1_mf_temp_jmhoczxb_.tmp  o1_mf_undotbs1_jmho9f8x_.dbf  o1_mf_users_jmho9gcd_.dbf

[oracle@vignesh datafile]$ rm -rf *

[oracle@vignesh datafile]$ ls

[oracle@vignesh datafile]$ cd

 

Kill the DB instance, if running. You can do shut abort or kill pmon at OS level

 

 [oracle@vignesh ~]$ ps -ef |grep pmon

oracle    8805     1  0 03:18 ?        00:00:00 ora_pmon_livedb

oracle   16319  3934  0 04:46 pts/2    00:00:00 grep --color=auto pmon

[oracle@vignesh ~]$ kill -9 8805

 

[oracle@vignesh ~]$ ps -ef |grep pmon

oracle   16330  3934  0 04:46 pts/2    00:00:00 grep --color=auto pmon

 

Start the DB instance and take it to Mount stage.

 

[oracle@vignesh ~]$ export ORACLE_SID=livedb

[oracle@vignesh ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 8 04:47:02 2021

Version 19.3.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup mount

ORACLE instance started.

 

Total System Global Area 1728050048 bytes

Fixed Size                  8897408 bytes

Variable Size             436207616 bytes

Database Buffers         1275068416 bytes

Redo Buffers                7876608 bytes

Database mounted.

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0

 

 Connect to RMAN and recover the database

 

[oracle@vignesh ~]$ export ORACLE_SID=livedb

[oracle@vignesh ~]$ rman target/

 

Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 8 04:48:25 2021

Version 19.3.0.0.0

 

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: LIVEDB (DBID=3038400691, not open)

 

execute the run command mention the level 0 and level 1 TAG

 

RMAN> run

{

RESTORE DATABASE from tag TAG20210908T043841;

RECOVER DATABASE from tag TAG20210908T044433;

RECOVER DATABASE;

sql 'ALTER DATABASE OPEN';

}

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=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_jmho76m8_.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_sysaux_jmho8n57_.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_undotbs1_jmho9f8x_.dbf

channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_users_jmho9gcd_.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_nnnd0_TAG20210908T043841_jmhw7s4x_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_nnnd0_TAG20210908T043841_jmhw7s4x_.bkp tag=TAG20210908T043841

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:45

Finished restore at 08-SEP-21

 

Starting recover at 08-SEP-21

using channel ORA_DISK_1

channel ORA_DISK_1: starting incremental datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

destination for restore of datafile 00001: /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_system_jmhwt5ld_.dbf

destination for restore of datafile 00003: /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_sysaux_jmhwt5n5_.dbf

destination for restore of datafile 00004: /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_undotbs1_jmhwt5pt_.dbf

destination for restore of datafile 00007: /u01/app/oracle/oradata/LIVEDB/datafile/o1_mf_users_jmhwt5pw_.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_nnnd1_TAG20210908T044433_jmhwlskb_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/LIVEDB/backupset/2021_09_08/o1_mf_nnnd1_TAG20210908T044433_jmhwlskb_.bkp tag=TAG20210908T044433

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

 

starting media recovery

media recovery complete, elapsed time: 00:00:00

 

Finished recover at 08-SEP-21

 

Starting recover at 08-SEP-21

using channel ORA_DISK_1

 

starting media recovery

media recovery complete, elapsed time: 00:00:00

 

Finished recover at 08-SEP-21

 

sql statement: ALTER DATABASE OPEN

 

RMAN> exit

 

 

Recovery Manager complete.

 

After complete recovery check the datafiles in that location

 

 [oracle@vignesh ~]$  cd /u01/app/oracle/oradata/LIVEDB/datafile/

[oracle@vignesh datafile]$ ls

o1_mf_sysaux_jmhwt5n5_.dbf  o1_mf_system_jmhwt5ld_.dbf  o1_mf_temp_jmhwvrfj_.tmp  o1_mf_undotbs1_jmhwt5pt_.dbf  o1_mf_users_jmhwt5pw_.dbf

[oracle@vignesh datafile]$ ls -lrth

total 1.8G

-rw-rw----. 1 oracle oracle 341M Sep  8 04:49 o1_mf_undotbs1_jmhwt5pt_.dbf

-rw-rw----. 1 oracle oracle 901M Sep  8 04:49 o1_mf_system_jmhwt5ld_.dbf

-rw-rw----. 1 oracle oracle 5.1M Sep  8 04:49 o1_mf_users_jmhwt5pw_.dbf

-rw-rw----. 1 oracle oracle  21M Sep  8 04:49 o1_mf_temp_jmhwvrfj_.tmp

-rw-rw----. 1 oracle oracle 551M Sep  8 04:49 o1_mf_sysaux_jmhwt5n5_.dbf

[oracle@vignesh datafile]$ cd

 

Check the database opened

 

[oracle@vignesh ~]$ export ORACLE_SID=livedb

[oracle@vignesh ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 8 04:50: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

 

Connect the user and check table rows are recovered, it can be done in level 1 backup

 

SQL> conn ogr/ogr

Connected.

SQL> select * from test;

 

    SERIAL NAME

---------- -----

         1 one

         2 Two

         3 Three

         4 Four

 

 

No comments:

Post a Comment

Oracle OS Management Hub in OCI – A Complete Overview

  Oracle OS Management Hub in OCI – A Complete Overview In any enterprise IT landscape, managing operating systems across hundreds of compu...