Wednesday 6 September 2017

Taking Hot Backup of Oracle Database

Introduction

Hot backup is run when the database is up and running, due to which its also called as inconsistent backup. Prerequisites for running hot backup is that, database should be in the archivelog mode. When we run hot backup there are chances of split block. Split block phenomenon occurs when the block which is getting copied is modified by DBWR during the backup operation. Any split blocks during the backup will be recovered using archivelogs or redologs. We have to enable begin backup mode for the database before intiating the copy of files. At this stage checkpoint happens and datafiles headers will be froze. However all the changes, I/O will be enabled on the datafiles and checkpoint increment will not happen 
Caution : Archivelog generation will be more during full backup

Running Hot Backup of Oracle Database

Step 1:- Check the list of data files, control files and redolog files in the database

SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/GGDB01/users01.dbf
/u01/app/oracle/oradata/GGDB01/undotbs01.dbf
/u01/app/oracle/oradata/GGDB01/sysaux01.dbf
/u01/app/oracle/oradata/GGDB01/system01.dbf
/u01/app/oracle/oradata/GGDB01/ggdata01.dbf

SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/GGDB01/redo03.log
/u01/app/oracle/oradata/GGDB01/redo02.log
/u01/app/oracle/oradata/GGDB01/redo01.log

SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/GGDB01/control01.ctl
/u01/app/oracle/flash_recovery_area/GGDB01/control02.ctl

Step 2:- Enable begin backup mode for the database

[oracle@prim backups]$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 22 19:35:45 2017
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database begin backup;


Database altered.

Step 3:- Now manually copy all the data files, control files and redolog files to backup location

$ cp /u01/app/oracle/oradata/GGDB01/users01.dbf /u01/app/backups/
$ cp /u01/app/oracle/oradata/GGDB01/undotbs01.dbf /u01/app/backups/
$ cp /u01/app/oracle/oradata/GGDB01/system01.dbf /u01/app/backups/
$ cp /u01/app/oracle/oradata/GGDB01/sysaux01.dbf /u01/app/backups/
$ cp /u01/app/oracle/oradata/GGDB01/ggdata01.dbf /u01/app/backups/
--------------------------------------------------------------------------------
$ cp /u01/app/oracle/oradata/GGDB01/redo01.log /u01/app/backups/
$ cp /u01/app/oracle/oradata/GGDB01/redo02.log /u01/app/backups/
$ cp /u01/app/oracle/oradata/GGDB01/redo03.log /u01/app/backups/
--------------------------------------------------------------------------------
$ cp /u01/app/oracle/oradata/GGDB01/control01.ctl /u01/app/backups/
$ cp /u01/app/oracle/flash_recovery_area/GGDB01/control02.ctl /u01/app/backups/

Step 4:- Go to backup location and list the files. This is to verify if all the files are present 

[oracle@prim backups]$ ls -ltr
total 1898144
-rw-r----- 1 oracle oinstall   5251072 Aug 22 19:36 users01.dbf
-rw-r----- 1 oracle oinstall  31465472 Aug 22 19:36 undotbs01.dbf
-rw-r----- 1 oracle oinstall 702554112 Aug 22 19:37 system01.dbf
-rw-r----- 1 oracle oinstall 503324672 Aug 22 19:38 sysaux01.dbf
-rw-r----- 1 oracle oinstall 524296192 Aug 22 19:38 ggdata01.dbf
-rw-r----- 1 oracle oinstall  52429312 Aug 22 19:39 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Aug 22 19:39 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Aug 22 19:39 redo03.log
-rw-r----- 1 oracle oinstall   9748480 Aug 22 19:40 control01.ctl
-rw-r----- 1 oracle oinstall   9748480 Aug 22 19:40 control02.ctl
[oracle@prim backups]$

Step 5:- After copy completes end the backup mode for database

SQL> alter database end backup;

Database altered.

Now we have successfully completed the Hot backup of Oracle database :)

During recovery below mentioned command can be used
SQL>recover database using contolfile autobackup untill cancel;

2 comments: