Please see my other blog for Oracle EBusiness Suite Posts - EBMentors

Search This Blog

Note: All the posts are based on practical approach avoiding lengthy theory. All have been tested on some development servers. Please don’t test any post on production servers until you are sure.

Sunday, March 27, 2011

About Netbackup

NetBackup integrates the database backup and recovery capabilities of the Oracle Recovery Manager (RMAN) with the backup and recovery management capabilities of NetBackup. NetBackup for Oracle also lets you export and import Oracle data in XML format for long-term archival and retrieval.

The server that hosts the Oracle database must be a NetBackup client.
How does NetBackup for Oracle work?
The following are prerequisites for performing backups to a storage unit:
■ Access to the NetBackup library
■ Generating unique file names
NetBackup for Oracle includes a library of functions that enable RMAN to use NetBackup. This library is in install_path\NetBackup\bin. When you use the RMAN backup command, each resulting backup set contains
at least one backup piece (data file, data file copy, control file, or archive log) from the target database. You must give each backup piece a unique name using the format operand. Several substitution variables are available to aid in generating unique names. You can specify the format operand in the backup command or in
the allocate channel command. NetBackup considers the backup piece name as the file being backed up, so this name must be unique in the catalog. Either NetBackup users or automatic schedules start database backups by specifying a template or shell script in the file list of the Oracle policy. The template or shell script specifies the backup commands that RMAN performs on the client.
For a backup:
■ The rman command starts the requested operation on the databases.
■ When the process requires media to store backup data, RMAN starts a user-directed backup by issuing a backup request.
■ The NetBackup media server connects to NetBackup for Oracle on the client and transfers the database data to secondary storage.
A restore works in essentially the same manner except that RMAN issues a restore request. This causes NetBackup to retrieve the data from secondary storage and send it to NetBackup for Oracle on the client.
RMAN supports parallel operations, so a single rman command can start more than one backup or restore on the NetBackup system.
The status for an RMAN operation is stored in the RMAN catalog or in the database control file. This same status is indicated by the output of the RMAN command used to run the backup or restore. This status is the only status that a database administrator must check to verify that a backup or restore has been successful.

NetBackup also logs status, but only for its own part of the operation. The database administrator cannot use the NetBackup status to determine whether rman was successful. Errors can occur in rman that do not affect NetBackup and are not recorded in its logs.

Specifying runtime environment variables when using shell scripts
Use the send command or the parms operand to specify NetBackup for Oracle environment variables for use during a backup or restore.
Example 1. This example uses the send command to specify the policy and server to use for a database backup. As this example shows, specify the variables in the string in the RMAN script after all channels have been allocated and before the backup command.

run {
allocate channel t1 type 'SBT_TAPE';
allocate channel t2 type 'SBT_TAPE';
send 'NB_ORA_POLICY=your_policy, NB_ORA_SERV=your_server’;
backup
(database format 'bk_%U_%t');
}

run {
           allocate channel t1 type 'SBT_TAPE'
           parms="ENV=(NB_ORA_POLICY=your_pol,
                       NB_ORA_SERV=your_server)";
          allocate channel t2 type 'SBT_TAPE'
          parms="ENV=(NB_ORA_POLICY=your_pol,
                              NB_ORA_SERV=your_server)";
      backup
      (database format 'bk_%s_%p_%t');
}


EXAMPLE: (backup_full_rman_nbu_tape.rcv)

RUN
{
    ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
    ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
    SEND 'NB_ORA_CLIENT=OR1, NB_ORA_SERV=nb1';
        BACKUP 
        FORMAT '%d_TP_%I_%T_%s_%p'
        TAG='DLY_DB_TPBKP_1547250382'
        FILESPERSET 5
        DATABASE include current controlfile;
    sql 'alter system archive log current';
    RELEASE CHANNEL ch00;
    # Backup all archive logs
    BACKUP
    FORMAT '%d_arcSq_%e_%T_%s_%p'
            FILESPERSET 20
            TAG='DLY_DB_TPBKP_ARC_1547250382'
            ARCHIVELOG ALL
            delete input;   
    RELEASE CHANNEL ch01;
 }

EXAMPLE: (backup_full_rman_nbu_disk.rcv)
RUN

{
    ALLOCATE CHANNEL ch01 TYPE DISK FORMAT 'D:\Backup\RMAN_TEMP\%d_DBDISK_%u_%s_%p';
   
    BACKUP
            TAG='DAILY_DB_DISKBKP'
            FILESPERSET 5
            DATABASE include current controlfile;
    sql 'alter system archive log current';
    RELEASE CHANNEL ch01;
    # Backup all archive logs
ALLOCATE CHANNEL ch01 TYPE DISK FORMAT 'D:\Backup\RMAN_TEMP\arch_%U';
    BACKUP
            FILESPERSET 20
            TAG='DAILY_DB_DISKBKP_ARCH'
            ARCHIVELOG ALL;
           
    RELEASE CHANNEL ch01;
 }



backup_full_rman_nbu.bat

 set ORACLE_HOME=D:\app\Inam\product\11.2.0\dbhome_1
set PATH=D:\app\Inam\product\11.2.0\dbhome_1\bin;
set RMAN_SCRIPT=Backup_Full_rman_nbu_tape.rcv
SET ORACLE_SID=DB1
set day=%date:~0,3%
set mm=%date:~4,2%
set dd=%date:~7,2%
set yy=%date:~-4%
set RMAN_LOG_NAME=Backup_Full_rman_nbu_tape_%yy%%mm%%dd%.log
#rman target sys/ORACLE11g@db1 CMDFILE=D:\Backup\rmanrelated\Scripts\netbackup\Backup_Full_rman_nbu.rcv LOG=D:\temp\netbackupLog\Backup_Full_rman_nbu_%yy%%mm%%dd%.log
rman target sys/ORACLE11g@db1 CMDFILE=D:\Backup\rmanrelated\Scripts\netbackup\%RMAN_SCRIPT% LOG=D:\temp\netbackupLog\%RMAN_LOG_NAME%

==========

CROSS CHECK Backupsets
The crosscheck backupset command operates on available and expired backup pieces. RMAN updates their status with the result (available or expired).
To cross-check a database, start RMAN and connect to the target database. Also connect to the recovery catalog if one is being used. At the rman command prompt, type the following commands:

allocate channel for maintenance type 'SBT_TAPE';
crosscheck backupset of database;
RMAN> allocate channel for maintenance type 'SBT_TAPE';

allocated channel: ORA_MAINT_SBT_TAPE_1
channel ORA_MAINT_SBT_TAPE_1: sid=1930 instance=db1 devtype=SBT_TAPE
channel ORA_MAINT_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 7.0 (20100707)

RMAN> crosscheck backupset of database;

crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=kvm71stv_1_1 recid=2189 stamp=745599937
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=bk_u%%u_s%%s_p%%p_t%%t recid=2195 stamp=746796420
Crosschecked 2 objects


Deleting obsolete backups
TheDELETEOBSOLETEcommanddeletes backups that no longer need to satisfy specified recoverability requirements.
Allocate channel for maintenance type 'SBT_TAPE';
DELETE OBSOLETE;

Deleting expired backups
The delete expired backupset command operates only on expired backup pieces that are found in the recovery catalog. RMAN removes them from the recovery catalog.
allocate channel for maintenance type 'SBT_TAPE';
delete expired backupset of database;




No comments: