BACKUP,RESTORE AND RECOVERY





 BACKUP,RESTORE AND RECOVERY:
 --------------------------------------------

 --> BACKUP TYPES
   
1) PHYSICAL BACKUP
2) LOGICAL BACKUP



  1) PHYSICAL BACKUP:
  ----------------------------

     --> BACKUP OF DATAFILES ,CONTROL FILES AND REDOLOG FILES
   
            COMPLETE BACKUP --> IF U TAKE ALL AS BACKP
    PARTIAL BACKUP  --> IF U TAKE NOT ALL AS BACKUP

     --> TYPES OF PHYSICAL BACKUP
    COLD BACKUP --> TAKING BACKUP WHEN DATABASE IS IN SHUTDOWN
    HOT BACKUP  --> TAKING BACKUP WHEN DATABASE IS RUNNING
                      (IN THIS WE CANT TAKE BACKUP THE CONTROL AND REDOLOG FILES)

     --> RMAN IS A TOOL FOR THE PHYSICAL BACKUP
     
   FOR RMAN --> RECOVERY_CATLOG_OWNER

     --> INCREMENTAL BACKUPS


  2) LOGICAL BACKUP :
  ---------------------------

     --> TAKING BACKUP THE DEFINITIONS AND IT'S DATA ALSO
     -->IN THIS WE TAKE
           --> ONLY SCHEMA
   --> SCHEMA + DATA


     --> LEVELS IN THIS

           --> DATABASE LEVEL
     --> TABLESPACE LEVEL
   --> USER LEVEL
   --> TABLE LEVEL
     --> PUT IN A DUM FILE
     --> TAKES LESS SIZE WHEN COMPARED TO PHYSICAL BACKUP
     --> IT TAKES MORE TIME THAN THE PHYSICAL BACKUP

     --> INCREMENTAL BACKUPS ( ONLY TAKING CHAGES AFTER THE LAST BACKUP)
     --> CUMULATIVE BACKUPS ( TAKING ALL INCREMENTAL BACKUPS)
     --> FULL BACKUP

     -->  UTILITIES FOR LOGICAL BACKUP( CLIENT TOOLS)

              --> EXP (FOR LOGICAL BACKUPS)
      --> IMP (FOR LOGICAL BACKUP RESTORE)
           
   --> FOR DATABASE BACKUP(EXP AND IMP)
         
                  EXP_FULL_DATABASE  --> ROLE FOR TAKING FULL DATABASE BACKUP
  IMP_FULL_DATABASE  --> ROLE FOR RESTORE THE DATABASE

         
           --> 10G ONWARDS
                 --> EXPDP
 --> IMPDP




backing up database:
--------------------

--> As an oracle DBA,one of your fundamental tasks is regularly backup databases

--> no backup, no recovery

--> backups are

    -- physical backups
        -- backing up of the key oacle database files:datafiles

    -- logical backups
        -- taking backup of definition and data also

--> the physical backups can perform in two ways

    -- user managed backups

        -- in this we use os commands cp and sql commands

    -- RMAN backups  
  
        -- used in command line and OEM databse control interface

--> backups are

    -- whole and partial backups
        -- taking all as backup is whole backup
        -- taking some as backup is partial backup

    -- consistent and inconsistent backups
        -- a consistent backup doesnot need to go through recovery process
        -- an inconsistent backup alwys needs to undergo a recovery

    -- open and closed backups
        -- online or open(hot backup) backups are you make while the database is open and accessible to 
              users
        -- a closed backup(cold backup) is made while the datbase is shutdown.its always consistent.

--> bakcup levels

    -- whole database

    -- tablespace backups

    -- datafile backups


--> flash recovery area as the default area for storing every file related to backup and restore operations

--> parameter to set the flash recover area size

    -- db_recovery_file_dest_size

       sql> alter system set db_recovery_file_dest=2G;



database recovery:
------------------

--> types of failures
  
    -- system failures
    -- data center disasters
    -- human errors
    -- media failures

--> recoveries are
    -- complete recovery
    -- incomplete recovery
        -- time based recovery
        -- change based scn
        -- log sequence based recovery

--> typical media recovery scenarios
    -- complete recovery of a whole database
    -- recovering a tablespace
    -- recovering datafile
    -- incomplete recovery
    -- recovering from the loss of control file
    -- recovering a datafile without a backup
  

user managed backups:
---------------------

--> in user managed backups,you can take backup by using os copy commands such as     cp and dd in unix, and the copy command in windows systems

--> if the database is in archive mode then we can take open batabase backup

--> if the database is in noarchive mode then we can take closed database backup

--> for backup we use sql command
    -- begin backup and end backup

--> the possible backups are

    -- whole open backup
    --partial database backups

--> whole open backup

    sql> alter database begin backup;

    sql> host cp /u01/app/oracle/oradata/orcl/*.dbf /u01/app/oracle/bck

    sql> alter database end backup;

--> partial database backups

    sql> alter tablespace users begin backup;

    sql> host cp /u01/app/oracle/oradata/orcl/users01.dbf /u01/app/oracle/bck

    sql> alter tablespace end backup;


--> views for monitoring backups

    v$backup    -- determining whether any of the datafiles are still in backup   mode
    v$datafiles -- about datafiles

    v$log        -- about online redologs

    v$archivelog -- about archive log information

    v$log_history -- redologs that have been archived

  
        sql> desc v$backup

             Name                                      Null?    Type
            ------------------ -------- ----------------------------
             FILE#                                              NUMBER
             STATUS                                        VARCHAR2(18)
             CHANGE#                                            NUMBER
             TIME                                               DATE


--> typical media recovery scenarios
    -- complete recovery of a whole database
        -- restore the datafiles from backup
        -- start the database in mount state
            sql> startup mount;
        -- recove the database
            sql> recover automatic database
        -- open the database
            sql> alter database open

    -- recovering a tablespace
        -- offline tablespace
            sql> alter tablesapce users offline immediate;
        -- restore the damaged file
            sql>  host cp /u01/orcl/users01.dbf  /uo1/bck/user01.dbf;
        -- recover the tablespace
            sql> recover tablespace users;
        -- online the tablespace
            sql> alter tablsepace users online;

    -- recovering datafile
        -- offline tablespace
            sql> alter tablesapce users offline immediate;
        -- restore the damaged file
            sql>  host cp /u01/orcl/users01.dbf  /uo1/bck/user01.dbf;
        -- recover the tablespace
            sql> recover tablespace users;
        -- online the tablespace
            sql> alter tablsepace users online;

    -- incomplete recovery
        -- shutdown the database
            sql> shutdown immediate;
        -- restore all the datafile and make sure that all of them are online
        -- choose the recovery option
            -- cancel based recovery
                sql> recover database until cancel;
            -- time based recovery
                       sql> recover database until time '2012-03-30:12:00:00';
                       sql> recover database until time '2012-03-30:12:00:00'
                    using backup controlfile;  
            -- change based recovery
                sql> recover database until change 27845;
        -- open the database with resetlogs option
            sql> alter database open resetlogs;

    -- recovering from the loss of control file

    -- recovering a datafile without a backup











    

No comments:

Post a Comment