Here we will discuss about requirement configure shell script, configure shell script to backup & schedule shell script for rman backup script to complete rman full backup using crontab in Linux, Solaris and Unix platform. Cron job will be triggered as per scheduled time.
How to schedule shell script for rman backup?
In this post will cover how to prepare backup script in oracle using below steps. We have already test in test instance and live environment as well for daily, weekly, monthly and yearly backup.
Below rman backup example will do the following task using script shell programming and scripting.
👉 Backup Oracle Home binary file using tar.
👉Backup the complete database, control file and all archive logs.
👉Crosscheck database rman backup and archive log.
👉Delete old backup which have taken before 4 days.
👉Delete expired archive log.
Here we can see example of rman backup script for crontab.
We can schedule script using crontab for rman full backup script for windows, shell script for rman duplicate & rman restore shell script.
Step 1: Prepare Shell Script: –
copy the entire shell script and create rmanbkp.sh file.
Shell Script: – /data01/crontab_scripts/rmanbkp.sh
#!/bin/ksh
#Created by Sajid Quamer
. /data05/11.2.0.4/PROD_db.env
destnation=/backup/rmanPROD/`date +”%A”_”%d-%m-%y”_”%T”`
export destnation
old=/backup/rmanPROD/Last_`date +”%A”_”%d-%m-%y”_”%T”`
export old
#cd /backup/archive_bkp/
mv $destnation $old
mkdir -p $destnation
#Cleanig OLD Backup
rm -rf $old
cd /backup/rmanPROD/
find . -name “*.rbkp” -mtime +10 -exec rm -rf {} ;
find . -name “*.tgz” -mtime +10 -exec rm -rf {} ;
Backing up Oracle Binary file.
cd $ORACLE_HOME
tar -cvzf $destnation/11.2.0.4.tgz *
rman target / nocatalog cmdfile=/data01/crontab_scripts/rmanbkp.sql log=$destnation/full_bkp_.log
cd /backup/rmanPROD/
find . -name “*.rbkp” -mtime +10 -exec rm -rf {} ;
find . -name “*.tgz” -mtime +10 -exec rm -rf {} ;
#Transfer RMAN backup to Backup Server (172.168.11.10)
#sh /acedata01/crontab_scripts/rmanFTP.sh
bkp=`date +”%A”`
cd $destnation
ftp -n 172.168.11.10 << !EOF
user orauat orauat1
prompt
bin
cd /backup/rmanPROD
mkdir $bkp
cd /backup/rmanPROD/$bkp
lcd $destnation
mput *.tgz
mput DB*
mput ARCBAK*
mput C*
mput *.log
quit
!EOF
Step 2: Prepare Rman Backup script: –
simply copy the below rman backup script to make rmanbkp.sql file to perform rman full backup script oracle 19c.
Rman Backup Script file:-
/data01/crontab_scripts/rmanbkp.sql
RUN
{
sql ‘alter system archive log current’;
BACKUP AS compressed backupset filesperset 8 DATABASE FORMAT ‘$destnation/DB_%d_%p_%T_%s.rbkp’ TAG DAILY_HOT_BACKUP;
sql ‘alter system archive log current’;
BACKUP AS compressed backupset ARCHIVELOG ALL NOT BACKED UP 1 TIMES FORMAT ‘$destnation/ARCBAK_%d_%p_%T_%s.rbkp’ TAG ARCHIVE_BKP;
BACKUP AS compressed backupset CURRENT CONTROLFILE FORMAT ‘$destnation/CNT_%d_%p_%T_%s.rbkp’ TAG CONTROL_FILE;
CROSSCHECK COPY;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE ARCHIVELOG UNTIL TIME ‘sysdate-4’ BACKED UP 1 TIMES TO DEVICE TYPE DISK;
DELETE EXPIRED BACKUP;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
}
exit;
For more information about restoration using rman backup check another post, click here.
Step 3: Schedule rman backup shell scripts: –
Crontab syntax: –
Basically, Crontab file has six fields for specifying minute, hour, day of month, month, day of week and the command to be run.
* * * * * command or scripts file to be executed.
| ||||
| | | |+—–>day of week (0 -6) (Sunday=0)
| | | +——->month (1 -12)
| | +———>day of month (1 -31)
| +———–>hour (0 -23)
+————->minute (0 -59)
Crontab examples to automate shell script which already have explain above. We can schedule job for rman weekly and daily backup script.
00 1 * * * /data01/crontab_scripts/rmanbkp.sh #Run at 01:00 am every day
00 20 * * * /data01/crontab_scripts/rmanbkp.sh #Runs at 08:00 pm every day
00 1 * * 0 /data01/crontab_scripts/rmanbkp.sh #Runs at 1:00 am every Sunday
00 1 * * 7 <command> #Runs at 1:00 am every Sunday
00 1 * * Sun <command> #Runs at 1:00 am every Sunday
30 8 30,31 * * /data01/crontab_scripts/rmanbkp.sh #Runs at 8:30 am on the last day of every month
30 22 01 01 * * /data01/crontab_scripts/rmanbkp.sh #Runs at 10:30 Pm on the 1st January of every year.
Referenes/Related:-
- runInstaller-Checking operating system version: must be redhat-2.1AS, redhat-3 or redhat-4 Failed
- Steps To Run The EBS Technology Code Level Checker (ETCC)
- Increase Open Files Limit to resolve Too Many Open files error and native OutOfMemory due to failed to create thread
- Steps to create physical standby database using rman backup
- ORA-1652: unable to extend temp segment by 128 in tablespace TEMP
- Restore and recover Pluggable Database (PDB) from rman backup
- How to delete concurrent program and executable in oracle apps
Thanks for sharing this blog.
Oracle course in Chennai
Clearly well articulated..So does this script mean that it takes a full backup of the entire database everyday?
Exactly, The script will do the entire database (Datafile,Controlfile and Archive log.) backup including binary file(required for Cloning on test/dev server).
How to discover best arrangement? More often than not this inquiry comes in the brain of the purchaser. voodoodreams
It was so nice article. I was really satisfied by seeing this article. SQL server dba Online Training Bangalore
I got an idea after reading your blog. Thanks a lot for sharing this content with us.
Spoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
Best Spoken English Classes in Chennai
Best Spoken English Institute in Chennai
Excellent Blog!!! Such an interesting blog with clear vision, this will definitely help for beginner to make them update.
RPA Training in Chennai
RPA Classes in Chennai
AWS Training in Chennai
Data Science Course in Chennai
Digital Marketing Course in Chennai
RPA Training in Anna Nagar
RPA Training in Adyar
I want to thank for sharing this blog, really great and informative. Share more stuff like this.
Ethical Hacking course in Chennai
Ethical Hacking Training in Chennai
Hacking course
ccna course in Chennai
Salesforce Training in Chennai
Angular 7 Training in Chennai
Web Designing course in Chennai
Ethical Hacking course in Thiruvanmiyur
Ethical Hacking course in Porur
Ethical Hacking course in Adyar
This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information.Oracle DBA Training in Bangalore
Hi Sir, It is well explained but can you clarify me the source and destination? also can i have contact number. also i wanted to know how to take DB location backup from one DB server to Another DB server using shell script.
Well as i understand your concern , You just want to move DB backup from source to other destination. To do so you should prepare shell script as below.
#!/bin/ksh
destination=/backup/rmanPROD/`date +"%A"_"%d-%m-%y"_"%T"`
export destination
bkp=`date +"%A"`
cd $destination
ftp -n 192.168.11.25 << !EOF
user orabkp orabkppassword
prompt
bin
cd /backup/rmanPROD — destination of another server.
mkdir $bkp
cd /backup/rmanPROD/$bkp
lcd $destination
mput *.tgz
mput DB*
mput ARCBAK*
mput C*
mput *.log
quit
!EOF
Destination Server:- 192.168.11.25 —where you want to move backup
You have to mention Username and password of Destination Server. You can copy above script and make shell script and put the shell script in backup shell script file. Once backup will complete , This shell script will transfer your backup from source to destination on another server.
Top Courses to learn
I am glad that I have visited this blog. Really helpful, eagerly waiting for more updates.
Great article with awesome and fantastic information.
AngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery
Thanks for this valuable information.
great article thanks for sharing oracle training in chennai
IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai Project Centers in Chennai
I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously
in their life, he/she can earn his living by doing blogging.Thank you for this articl
Oracle DBA Training in Bangalore
nice post.oracle dba training
oracle dba online training
Great post. Thanks for sharing…..
RPA Training in Bangalore
RPA Course in Bangalore