Nov 30, 2014

Shell script to run rman backup in oracle

#!/bin/sh
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_BASE=/u01/app/oracle


rman target / << EOF
run {
    # configure retention policy to recovery window of 2 days;
    configure retention policy to redundancy 1;
    configure controlfile autobackup on;

    # crosscheck backup pieces
    crosscheck backup;
    crosscheck archivelog all;

    # delete expired backups
    delete noprompt expired backup;
    delete noprompt expired archivelog all;

    # backup database, archivelog, controlfile
    backup database plus archivelog;

    # verify database, archivelog, controlfile, and spfile
    restore database validate;
    restore archivelog all validate;
    restore controlfile validate;
    restore spfile validate;

    # force cleanup
    delete noprompt obsolete device type disk;

}
EOF

exit 0

No comments: