Tag: Shell Script

  • SCN Based RMAN backup in nohup

    In this article, I would like to demonstrate how to create a shell script to perform an RMAN SCN based backup and execute in background. 



    Tip: Scripting is a powerful tool to automate and execute jobs in background.


    Below example shows how to perform an SCN based RMAN Incremental backup using 4 Channels when we perform Roll-forward of Physical Standby.

    Step 1. Make a RMAN command file with RMAN Commands.


    Create a cmd script and include RMAN backup command.



    Get current SCN of Physical Standby and select a location to store RMAN backup files.


    SQL> column BYTES current_scn 99999999999999
    SQL> select current_scn from v$database;
    CURRENT_SCN
    ———–
    7707430599033

    $ cd /orac01/orclprd_standby
    $ vi SCN_based_backup.cmd
    run
    {
    allocate channel t1 type disk ;
    allocate channel t2 type disk ;
    allocate channel t3 type disk ;
    allocate channel t4 type disk ;
    backup incremental from scn 7707430599033 database format ‘/ora01/orclprd_standby/stnd_backp_%U.bak’;
    release channel t1;
    release channel t2;
    release channel t3;
    release channel t4;
    }

    Step 2. Prepare shell script and include above .cmd RMAN



    $ vi rman_scn_based_incremental_bkup_for_standby.ksh
    #!/bin/ksh
    export ORACLE_SID=orclprd
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db
    export PATH=$PATH1:$ORACLE_HOME/bin
    rman target /   msglog /ora01/orclprd_standby/rman_SCN_backup.log cmdfile=/ora01/orclprd/RMAN_SCN_backup_from_primary/SCN_ based_backup.cmd

    Step 3. Change permissions of above shell scripts



    $ chmod 755 rman_scn_based_incremental_bkup_for_standby

    Step 4. Start RMAN using nohup to run in background



    $ nohup ./rman_scn_based_incremental_bkup_for_standby &




    Monitor RMAN log


    $ tail -300f /ora01/orclprd_standby/rman_SCN_backup.log




    Conclusion:  In this article we have learned how to perform RMAN SCN based backup using Unix shell script. Incremental backup are very useful such as rolling forward an standby database.






    Author : Hameed