Backing Up the Protected Database Using the Command Line

Use regular RMAN commands to create backups of your protected database. To schedule protected database backups, create a script that contains the required backup commands and then use any scheduling utility to schedule backups. You can create full backups, incremental backups, archived redo log backups, control file backups, or backups of specific data files and tablespaces. To implement the incremental-forever backup strategy, you need one level 0 incremental database backup and successive periodic level 1 incremental backups.

Because multiple protected databases are backed up to the same Recovery Appliance, backup piece names must be unique across all protected databases. Use the substitution variables %d_%U in the FORMAT string of BACKUP commands to ensure that backup piece names are unique.

See Also:

Oracle Database Backup and Recovery Reference for information about the substitution variables

To implement the incremental-forever backup strategy using the command line:

  1. Create a full backup of the protected database that will form the basis of the incremental-forever backup strategy as described in "Creating the Initial Full Backup of the Protected Database".
  2. Create and schedule regular level 1 incremental backups that include archived redo logs as described in "Creating Incremental Backups of the Protected Database".

Creating the Initial Full Backup of the Protected Database

This section describes how to create a one-time full backup of the whole protected database that includes archived redo logs. Assume that the protected database is in ARCHIVELOG mode and is configured to automatically back up the control file and server parameter file.

To create a full backup of the whole protected database:

  1. Connect RMAN to the protected database as TARGET and the Recovery Appliance catalog as CATALOG.
  2. Ensure that the configuration steps described in "Enrolling the Protected Database with Recovery Appliance" and "Configuring Backup and Recovery Settings for Protected Databases (Command Line)" are completed.
  3. Run the following command to allocate three SBT channels for the Recovery Appliance and then create a full backup of the protected database including archived redo log files:
    RUN
    {
     ALLOCATE CHANNEL c1 DEVICE TYPE sbt_tape 
       PARMS='SBT_LIBRARY=/u01/oracle/product/11.2.0.4/dbhome_1/lib/libra.so,
       ENV=(RA_WALLET=location=file:/u01/oracle/product/11.2.0.4/dbhome_1/dbs/ra 
       credential_alias=ra-scan:1521/zdlra5:dedicated)'
       FORMAT'%U_%d';
     ALLOCATE CHANNEL c2 DEVICE TYPE sbt_tape 
       PARMS='SBT_LIBRARY=/u01/oracle/product/11.2.0.4/dbhome_1/lib/libra.so,
       ENV=(RA_WALLET=location=file:/u01/oracle/product/11.2.0.4/dbhome_1/dbs/ra
       credential_alias=ra-scan:1521/zdlra5:dedicated)'
       FORMAT'%U_%d';
     ALLOCATE CHANNEL c3 DEVICE TYPE sbt_tape 
       PARMS='SBT_LIBRARY=/u01/oracle/product/11.2.0.4/dbhome_1/lib/libra.so,
       ENV=(RA_WALLET=location=file:/u01/oracle/product/11.2.0.4/dbhome_1/dbs/ra
       credential_alias=ra-scan:1521/zdlra5:dedicated)' 
       FORMAT'%U_%d';
     BACKUP DEVICE TYPE sbt
      TAG 'db_full_incr'
      CUMULATIVE INCREMENTAL LEVEL 1
      DATABASE FORMAT '%d_%U'
      PLUS ARCHIVELOG FORMAT '%d_%U' NOT BACKED UP;
    }
    

    The BACKUP ... INCREMENTAL LEVEL 1 command automatically creates a level 0 backup if no level 0 backup already exists.

Creating Incremental Backups of the Protected Database

This section describes how to create a script that performs level 1 incremental backups of the whole protected database and schedule this script to be run at 1 am every day. The backup includes archived redo log files. You can use any job scheduler, including adding your customized RMAN script in an RMAN job in Cloud Control, to schedule the RMAN script to be run at a specified time every day.

To create and schedule a level 1 incremental backup that includes archived redo log files:

  1. Ensure that the configuration steps described in "Enrolling the Protected Database with Recovery Appliance" and "Configuring Backup and Recovery Settings for Protected Databases (Command Line)" are completed.
  2. Ensure that at least one RMAN SBT channel that corresponds to the Recovery Appliance is configured as described in "Using RMAN Channels for Recovery Appliance Backup and Recovery Operations".
  3. Note:

    The backup command in this sections applies when the ZDLRA is the only backup destination. However, if implementing a dual backup strategy, follow either:

    Open a text editor and create and save a file with the following contents.

    Save the file in a directory that is accessible to the Oracle Database software and on which the Oracle software owner has the read permission. This script file is saved as /u01/app/oracle/product/11.2.0.4/db_home1/db_incr_daily.sh. The CONNECT CATALOG line below requires the appropriate password instead of myPassword.

    export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
    export ORACLE_SID=db1124sm
    export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/Opatch
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:/lib:/usr/lib;
    export LD_LIBRARY_PATH
    export LOG_TRACE_DIR=$HOME/RA_TEST/RMAN_SCRIPTS/LOG
    dt=`date +%y%m%d%H%M%S`
    $ORACLE_HOME/bin/rman log=$LOG_TRACE_DIR/rman_bkincr_log_db1124sm_$dt.log <<EOF
    CONNECT TARGET /
    CONNECT CATALOG rauser/myPassword@ra-scan:1521/zdlra5:dedicated
    
    BACKUP DEVICE TYPE SBT
       TAG 'db_full_incr'
       CUMULATIVE INCREMENTAL LEVEL 1 
       DATABASE FORMAT %d_%U'
       PLUS ARCHIVELOG FORMAT '%d_%U' NOT BACKED UP;
    EOF
    
  4. Log in to the protected database host as a user who is a member of the OSBACKUPDBA operating system group.

    See Also:

    Oracle Database Administrator’s Guide for information about the OSBACKUPDBA group
  5. Open a text editor, create a file with the following contents, and save the file using the name.crontab into your home directory. This example uses the crontab utility to schedule the RMAN script.
    MAILTO=first.last@example.com
    # MI HH DD MM DAY CMD
      00  1  *  *  *  /u01/app/oracle/product/11.2.0.4/db_home1/db_incr_daily.sh
    
  6. In a command window, change directory to your home directory and enter the following command to create a crontab file for this user from the contents of .crontab.
    # crontab .crontab