Vous êtes sur la page 1sur 5

PHYSICAL BACKUP AND RECOVERY

(os­Redhat linux, rdbms­oracle 9i, using spfile)

Types of Physical Backup:
1 Off line backup or Cold backup
2 On line backup or Hot Backup

Cold Backup or Offline backup:­

If we want to take offline backup/cold backup the database has to be shutdown using proper shutdown 
modes.

Step 1:

SQL> Shutdown normal; or
SQL> Shutdown Transactional; or
SQL> Shutdown Immediate;

SQL> shutdown normal
Database closed.
Database dismounted.
ORACLE instance shut down.

Step 2:
Copy all the physical files using OS copy command. Then startup the Database. (better to use scp or 
tar)

(Note: Files to backed up when database is shutdown are datafile, redolog file, control file, parameter 
file, password file, network files)

Step 3:
Startup the database normally.

SQL> startup
ORACLE instance started.

Total System Global Area   97587500 bytes
Fixed Size                   450860 bytes
Variable Size              46137344 bytes
Database Buffers           50331648 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.

Advantages of Cold Backup or Offline Backup:­

Compare to any other backup it is easy to take.
Minimum number of commands are necessary to perform cold backup (Shutdown & cp commands 
only)
Can automate easily to take the backup as the process are less
Is reliable, as no transaction takes place the database is closed.

Disadvantages of Cold Backup or Offline Backup:­

Unacceptable when the database must available continuously.(No use in 24/7 type of database)
The amount of time that the database unavailable is affected by
i Size of the Database. (If u r db is in tearbytes, then it will take very long time to copy the files)
ii The no. of physical files to be copied. (If u have many no. of table space and data files)
iii Speed of copy operation. (Depend on the OS capacity, Net work capability also)
Recover is possible up to the backup taken & the transaction done as data insertion after the backup is 
lost.

Hot Backup or Online Backup:­

Database Must be in archive log mode to take Hot Backup i.e., to perform online backup.

(Note:­  If database is not in archive log mode we can't place the table space to backup mode)

Advantages of Hot Backup: 

Database backup can be taken when databases is running i.e., available for users.
Can be used for database which must be available continuously and also 24/7 type of database.

Disadvantages of Hot Backup:

Additional Space is required to store and maintain the archive log files. 
During Hot backup additional redo is generated and hence more archive log files are created because of 
this database performance will be affected.

Step 1: 
Switch the redo log file manually. ( This step is optional)

SQL> alter system switch logfile;

System altered.

Step 2:
Using archive log list command note down the oldest log sequence  number.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /orcl/srinivas.dk/sriny/archive/arch
Oldest online log sequence     9
Next log sequence to archive   10
Current log sequence           10

Check the no. of table spaces you have to back up
SQL> select * from v$tablespace;

       TS# NAME                           INC
­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ ­­­
         0 SYSTEM                         YES
         1 DTEMP                          YES
         2 USR                            YES

Step 3:
Place the table space to backup mode.
SQL> alter tablespace system begin backup;

Tablespace altered.

Step 4:
Using OS copy Command copy the data files belonging to the table space to the backup location.
$ cp system.dbf /orcl/srinivas.dk/hotbackup/hb_13/

Step 5:
Using alter tablespace command end tablespace backup mode.
SQL> alter tablespace system end backup;

Tablespace altered.

Step 6:
Repeat step no. 3, 4 & 5 for all the required table spaces.

  { SQL> alter tablespace usr begin backup;

Tablespace altered.

]$ cp usr01.dbf /orcl/srinivas.dk/hotbackup/hb_13

SQL> alter tablespace usr end backup;

Tablespace altered. }

Step 7:
Switch the log file manually.

SQL> alter system switch logfile;

System altered.

Step 8:

Using archive log list command again note the oldest log sequence number.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /orcl/srinivas.dk/sriny/archive/arch
Oldest online log sequence     10
Next log sequence to archive   11
Current log sequence           11
Step 9:
Copy all the archive log files generated during hot backup period that is between first oldest log 
sequence number i.e., 9  to the last oldest log sequence number and i.e., 10  to the Backup location.

[srinivas.dk@yis­007 archive] $ cp arch_1_9 /orcl/srinivas.dk/hotbackup/hb_13/
[srinivas.dk@yis­007 archive] $ cp arch_1_10 /orcl/srinivas.dk/hotbackup/hb_13/

The Complete Backup Set in the Backup Location comprises of
i) Data files of all required table space.
ii) Archive log files from log sequence number 9 to 10 (in this above example)

To  check the view to which tablespaces are in backup mode.

SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­ ­­­­­­­­­­ ­­­­­­­­­
         1 NOT ACTIVE              67164 13­MAY­08
         2 ACTIVE                       67505 13­MAY­08 (This table space is in Backup mode)

Vous aimerez peut-être aussi