Monday, 20 July 2015

RMAN Refresh (POINT IN TIME RECOVERY)

  1. The variables that will be used in the document and their explanation are as follows:         

FROM_SERVER        = Where production database is up and running.
TO_SERVER              = Where the duplicate database will be up and running.
FROM_DATABASE  = Production database that has been backed up using RMAN
TO_DATABASE        = The database to be refreshed on

Make sure the filesystems on Production (FROM_SERVER) exactly match the filesystems on the Dev/UAT (TO_SERVER) server.

In case there is a difference in the filesystems layout or directory structure of the source and the target server; contact server team

Make sure there is enough space in /data/oracle//backup to store the backup pieces from .

          Log in to

Make directory to keep the backup pieces of and scripts

           $mkdir –p /data/oracle//backup//script


A.      TO REFRESH FROM CURRENT BACKUP ON

Copy the following files from FROM_SERVER to TO_SERVER using the “scp –p” command.

          Log in to

                - All RMAN backup pieces including archive logs pieces.

                        $ scp –p /data/oracle//backup/database/*rmn  
                            :/data/oracle//backup/           
                             
            - A backup controlfile (*ctl*Z or *ctl*gz) or the file generated from controlfile autobackup (c-*).
                        $ scp –p /data/oracle//backup/database/*ctl*Z
                             :/data/oracle//backup/

                        OR

                        $ scp –p /data/oracle//backup/database/*ctl*gz
                             :/data/oracle//backup/

                       OR
       
                       $scp –p /data/oracle//backup/database/c-*
                         :/data/oracle//backup/

                - A duplicate script (duplicate*.ksh) that dbbackup generates a template to clone database.

                        $ scp –p /data/oracle//backup/database/duplicate*.ksh
                             :/data/oracle//backup/

                - A backup init.ora file.

                        $ scp –p /data/oracle//backup/database/init*
                             :/data/oracle//backup/

               
              - A controlfile creation script generated from dbbackup. It is used to add temporary files after
                open resetlogs.

                   $ scp –p /data/oracle//backup/database/create_control*sql
                             :/data/oracle//backup/
    
   It is important to use "scp -p" to preserve the original file timestamp, when the above files are transferred to the host where RMAN refresh will be implemented.

B.      TO REFRESH FROM PREVIOUS RMAN BACKUP

Restore required RMAN backup files to the from tape

After restore to the “touch” one of the controlfiles on as:

$touch /data/oracle//backup//

  1. Four refresh scripts need to be copied to the refresh host from
                                                                      US golden::/export/applications/oracle/rman/refresh

                - refresh.ksh                      - is main script that will be executing RMAN refresh.
                - refresh.begin                  - is one of templates to generate a running script start_refresh.ksh
                - refresh.end                     - is one of templates to generate a running script start_refresh.ksh
               - rman_refresh.config    - is a configuration file needed to be customized

              Log in to US golden and :

               $ scp –p /export/applications/oracle/rman/refresh/refresh* 
                          :/data/oracle//backup//script

               $ scp –p /export/applications/oracle/rman/refresh/ rman_refresh.config
                          :/data/oracle//backup//script

   No modification is required for refresh.ksh, refresh.begin  and refresh.end.



  1. Log in to

-          Change directory to /data/oracle//backup//script
-          Update the parameters in rman_refresh.config

               In most cases, we only need to update TO_ORACLE_SID, BACKUP_DIR, BASE_DATA_DIR and
               INIT_ORA_OVERWRITE
               
               TO_ORACLE_SID               - is the database to be refreshed (SID name at TO
                                                               location)
                BACKUP_DIR                      - / data/oracle//backup/
                                                            is the directory where source database backup pieces, init.ora,
                                                             backup controlfile, duplicate script and controlfile creation script
                BASE_DATA_DIR               - is the base directory where the database is to be refreshed.
                INIT_ORA_OVERWRITE  - determines if init.ora is generated from the source
                                                             init.ora (Y if init.ora is created from the backup one.
                                                                   N if existing init.ora is reused, but ensure 
                                                                   UNDO_TABLESPACE uses same tablespace as the source database.
              
   The following parameters need to be modified ONLY IF a special filename or script is used:
              DUPLICATE_SCRIPT                   -  is a duplicate script created by dbbackup.
              CONTROLFILE_SQL                    - is a source database controlfile creation sql script
              BACKUP_CONTROLFILE      - is either a backup controlfile or a file generated from autobackup
   We can take default value for the following parameters:
             CLEANUP                                   - is a flag for housekeeping for refresh process. Turn off CLEANUP for
                                                                debugging.
            TRACE                            - determines whether "set -vx" is enabled or not. Useful for debugging.
              ARCHIVING                             -   determines if the database to be refreshed runs in ARCHIVE/NOARCHIVE
                                                         mode.
            RMAN_TARGET_LOGIN  -  determines how to connect to database instance.
            ABORT_ON_ERROR        - determines whether the refresh script aborts or not when an error occurs.

  1.  To perform refresh to the time of backup, go to step 6.
  2. To perform point-to-time recovery
               Setting RECOVER_UNTIL_TIME parameter in rman_refresh.config will enable point-to-time
               Recovery.

a.       If the point in time is a time before the backup was taken then:

                            In the rman_refresh.config update the RECOVER_UNTIL_TIME as "MM-DD-YYYY:HH24:MI:SS".

                            Go to step 5. And run the refresh.ksh

b.      If the time to recover is (far) ahead of the previous RMAN backup, it means the backup controlfile or autobackup controlfile from dbbackup may be obsolete. 

The following list steps to make point-to-time recovery work:

                           - Make sure dbbackup version should be 4.09 or higher (can be seen on the second line of
                              backup.log)

                           - Make sure controlfile autobackup is enabled for the . To see the
                             conguration do the following:

                                  Log in to
                                  Log in or sudo – su to
                                  $ rman target /
                                  RMAN> show all;

                                  If not already configured or the value is OFF, give the following command:

                                  RMAN> configure CONTROLFILE AUTOBACKUP ON;
                                  RMAN> exit;
                                    
                                  Run "arc2adsm.ksh -f $ORACLE_SID" forces to perform rman backup for archive logs and
                                  generates new  autobackup controlfile for the source database.

                                 $/data/oracle//admin/DBBACKUP/scripts/arc2adsm.sh –f $ORACLE_SID
                         
                          - Copy latest rman backup pieces and autobackup controlfile to the backup directory on the
                             server using the commands in step 1.

  1. Run the refresh.ksh script on the to get the database refreshed on the

-          Log in to
-          Change directory to /data/oracle//backup//script
               $ cd /data/oracle//backup//script
-          Run the script refresh.ksh
               $ nohup refresh.ksh &
-          Monitor the refresh process
               $ tail –f nohup.out

  1. Please ensure the log file for the refresh is stored in the following location normally /data/oracle//admin/logs;
            $ORA_ADMIN/logs/refresh_${ORACLE_SID}_$(date +%Y%m%d).log

  
  The potential issues:
        - point-to-time recovery may fail if a tablespace name or data file is dropped because the duplicate

          script from dbbackup becomes obsolete.

4 comments: