Description:-
In this article we are going to see about how to Take RMAN Backup using shell script on crontab
Demo:-
Step 1. Prepare a RMAN command file
Create shell script to take rman backup
[oracle@Prod22 backup]$ cat rman_bkp.sh
export ORACLE_SID=oradbwr
export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
rman target / nocatalog log=/u02/backup/RMAN_backup.log << EOF
run
{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
sql ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
configure retention policy to recovery window of 5 days;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
CROSSCHECK BACKUP DEVICE TYPE DISK;
CROSSCHECK ARCHIVELOG ALL;
delete noprompt archivelog all backed up 1 times to device type disk;
backup incremental level 0 as compressed backupset database archivelog all tag weekly_Full_backup delete input;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED BACKUP;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
EOF
Step 2. Change the permission
Change the permission of the shell script.
chmod 744 rman_bkp.sh
Step:-3 Schedule rman backup on crontab
Schedule backup will run at 10:00 PM every day.Add the below entry in crontab.
[oracle@Prod22 backup]$ crontab -l
###Rman Backup####
22 00 * * * /u02/backup/rman_bkp.sh
Connect with me on:-
Telegram App:https://t.me/oracledbwr
LinkedIn:https://www.linkedin.com/in/hariprasathdba
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page : https://www.facebook.com/dbahariprasath/?
Twitter : https://twitter.com/hariprasathdba