How to take RMAN INCREMENTAL LEVEL 1 Cumulative Backup using Shell script

Create the following backup path:-
[oracle@server1 ~]$ mkdir -p /u01/backups/rman_backup/inc_level_1_cum
[oracle@server1 ~]$ mkdir -p /u01/backups/scripts/


Make sure database is in archivelog mode , if its not put it on archivelog mode.

SQL> sqlplus / as sysdba
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;


[oracle@server1 ~]$  vi /u01/backups/scripts/IncLevel_1_Cum_rman_backup.sh

#!/bin/bash
export PS1="`/bin/hostname s`> " 
export ORACLE_SID=prim
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
export path1=/u01/backups/rman_backup/inc_level_1_cum
date1=`date +%d%m%y_%H%M%S`
mkdir $path1/$date1
chown oracle:oinstall -R $path1/$date1
su - oracle -c "$ORACLE_HOME/bin/rman target / " <<eof
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
report obsolete;
delete Noprompt obsolete;
configure CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$path1/$date1/control_%d_%F';
backup incremental level 1 cumulative database FORMAT '$path1/$date1/inc_level_1_cum_%d_%T_%t_%s_%p'; 
eof



[oracle@server1 ~]$ chmod 755 /u01/backups/scripts/IncLevel_1_Cum_rman_backup.sh

Now schedule the script using crontab from oracle user:-
The  script will run every 6 hours

[oracle@server1 ~]$ crontab -e

0 */6 * * * /u01/backups/scripts/IncLevel_1_Cum_rman_backup.sh > /dev/null

No comments:

Post a Comment