Friday, March 10, 2017

RMAN Backup Script

Creating an RMAN backup script to backup your Oracle database is not a big deal, but taking into consideration the options that Oracle add to RMAN tool, plus avioding code mistakes, I've created the following script to make this take more faster and easier:

Download:
https://www.dropbox.com/s/l3g17oxz6j56cdz/RMAN_full.sh?dl=0

This script should run by the Oracle installation owner (e.g. oracle). It will ask you to select the database you need to backup, then it will ask for the backup location, and the number of channels you want to use during the backup, then you will be offered to use special features such as Compression and Encryption, and finally the RMAN script will be created and will run automatically in the background in nohup mode, so no need to bother if your session get disconnected during the backup operation.


Tuesday, January 17, 2017

Script to delete applied archivelogs on a STANDBY database

This script is designed to run against STANDBY databases to deleted applied archives older than specific number of hours defined by the user. It maintains that un-applied archives remain un-touched.

Download the script:
https://www.dropbox.com/s/xx5o6b94rv5ps30/delete_applied_archives_on_standby.sh?dl=0


How to use the script:

⏩ Set MAIL_LIST variable to your E-mail to receive an email alert if archives are not applied. 
    e.g. MAIL_LIST="john.smith@abc.com"

Specify the candidate archives for deletion older than N hours by setting LAST_N_HOURS variable to the number of hours.

    e.g. Deleting applied archives older than 24 hours:
     LAST_N_HOURS=24

⏩ You can EXCLUDE any instance from having the script to run against by passing the INSTANCE_NAME you want to exclude to EXL_DB variable.

e.g. excluding orcl from archive deletion:

EXL_DB="\-MGMTDB|ASM|orcl"

⏩ You can use FORCE option when deleting the archives from RMAN console: [Y|N] [Default is NO]
    e.g. FORCE_DELETION=Y

⏩ You can decide to CROSSCHECK the archivelogs after the archivelogs deletion: [Y|N] [Default is YES]
    e.g. VALIDATE_ARCHIVES=Y

⏩ Also you can schedule it to run periodically in the Oracle's user crontab as well.

DISCLAIMER: THIS SCRIPT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY. IT IS PROVIDED "AS IS".