The
following procedure uses the "cron" utility to schedule daily
database RMAN backups at 8:00 a.m EXCEPT Friday.
Task-1: create RMAN Backup Script
Start a text editor and create and save a file with the following contents. Save the file in a directory that is accessible to the Oracle Database software and on which the Oracle software owner has the read permission.
#
vi rmandiskbkp.sh
export
ORACLE_BASE=/u02/app/oracle
export
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1
export
ORACLE_SID=dcpdb1
export
PATH=$ORACLE_HOME/bin:$PATH
export
TZ=GMT6
dt=`date
'+%d%m%Y%H%M'`
rman
target rmanbkp/rmanbkp <<eof
sql
'alter system archive log current';
run{
allocate
channel c1 type disk;
allocate
channel c2 type disk;
allocate
channel c3 type disk;
allocate
channel c4 type disk;
allocate
channel c5 type disk;
allocate
channel c6 type disk;
allocate
channel c7 type disk;
backup
AS COMPRESSED BACKUPSET full database tag T24_DB_$dt format
'/db_rmanbackup/t24_db_%p_%s_$dt.bkp';
sql
'alter system archive log current';
backup
current controlfile tag T24_CTL_$dt format
'/db_rmanbackup/t24_ctl_%p_%s_$dt.bkp';
backup
spfile tag T24_SPF_$dt format '/db_rmanbackup/t24_spf_%p_%s_$dt.bkp' ;
release
channel c1;
release
channel c2;
release
channel c3;
release
channel c4;
release
channel c5;
release
channel c6;
release
channel c7;
}
exit
eof
#
Task-2: Test RMAN backup Script
if
script is in the file /u02/app/oracle/rmandiskbkp.sh, then enter this command:
#
sh /u02/app/oracle/rmandiskbkp.sh
Task-3: Scheduling RMAN Backup Script
Entry
to “crontab”. To entry in “crontab”, then enter this command:
# crontab –e
[Edit]
In
“crontab” below following entry will
place:
#
MI HH DD MM DAY CMD
30
08 *
* 0,1,2,3,4,6 sh /u02/app/oracle/rmandiskbkp.sh -b 172.xx.xx.xx
So, By this setting RMAN backup will RUN everyday at 8:30AM except Friday.
Appendix:
# crontab –l [List]
Crontab Fields and Allowed Ranges
Field
|
Description
|
Allowed Value
|
MI
|
Minute
field
|
0
to 59
|
HH
|
Hour
field
|
0
to 23
|
DD
|
Day
of Month field
|
1
to 31
|
MM
|
Month
field
|
1
to 12
|
DAY
|
Day
of week field
|
0
to 6
|
CMD
|
Command
|
Any
command to be executed
|
DAY: 0 to 6: SUN,MON,TUE,WED,THU,FRI,SAT
No comments:
Post a Comment