Scripts For Backup

This Script Will Let you choose One Of three Type Of backup , All you have to do right the backup scripts to make the below script read it and run it :

#!/bin/bash
ORACLE_SID=ORCL;export ORACLE_SID
echo $ORACLE_SID
echo “Please Specify the kind of backup you want to take”
echo “1) COLD BACKUP”
echo “2) HOT BACKUP”
echo “3) EXPORT BACKUP”
echo “Enter your option”
read option
 while [ $option -gt 3 ]||[ $option -le 0 ]
do
echo “Please Enter the correct option”
read option
done
case $option in
1|2) echo “You are taking rman backup of DB”
   rman target sys/sys @/oracle/product/11g/rman_backup_$option.txt;exit;;
3) echo “You are taking export backup of DB”
   exp system/sys file=/oracle/exp_dat.dmp log=/oracle/exp_dat.log full=y;
   exit;;
esac
exit

 The above script can call anyone of the following rman script depending upon the user who wants take cold or hot backup

The content of rman_backup_1.txt

run {
   shutdown immediate;
   startup mount;
   allocate channel dup1 device type disk;
   allocate channel dup2 device type disk;
   backup format ‘/oracle/%U’ database;
   release channel dup1;
   release channel dup2;
   alter database open;
  }

The content of rman_backup_2.txt

run {
allocate channel dup1 device type disk;
allocate channel dup2 device type disk;
backup format ‘/oracle/%U’ database;
backup format ‘/oracle/arch_%U’ archivelog all;
backup format ‘/oracle/ctl_%U’ current controlfile;
release channel dup1;
release channel dup2;
}

Thank you
Osama mustafa 

Working with RMAN Stored Scripts

Creating Stored Scripts: CREATE SCRIPT

 

Make sure RMAN is connected to the right target database and the recovery catalog. Then run the CREATE SCRIPT command, as shown in this example:

 
 
CREATE SCRIPT full_backup 
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE OBSOLETE;
 
 

 you can also provide a COMMENT with descriptive information:

CREATE GLOBAL SCRIPT global_full_backup 
COMMENT 'use only with ARCHIVELOG mode databases'
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE OBSOLETE;
}

Running Stored Scripts: EXECUTE SCRIPT

 

RUN { EXECUTE SCRIPT full_backup; }

Displaying a Stored Script: PRINT SCRIPT

PRINT SCRIPT full_backup;
PRINT SCRIPT full_backup TO FILE 'my_backup.txt'; 

Listing Stored Scripts: LIST SCRIPT NAMES

LIST SCRIPT NAMES;

LIST ALL SCRIPT NAMES;

Updating Stored Scripts: REPLACE SCRIPT

REPLACE SCRIPT full_backup 
{
BACKUP DATABASE PLUS ARCHIVELOG;
}

Deleting Stored Scripts: DELETE SCRIPT

 

DELETE SCRIPT 'full_backup';
DELETE GLOBAL SCRIPT 'global_full_backup'; 

 

 

 

 Thank you 

Osama mustafa