Shell Script With Sample Examples

------------- Shell Script To perform complete Database with RMAN backup -----------------------


[oracle@primaryDB u01]$   cat backup.sh
#!/bin/ksh
rman target / log = "/u01/rman_log.log"  <<EOF
run {
backup database plus archivelog;
}
EXIT;
EOF



------ Stored the RMAN backup in logfile with Date Format ---------------------

[oracle@primaryDB u01]$ vi backup_full.sh
#!/bin/ksh
DATE_TIME=`date +%m.%d.%y.%H:%M:%S`
LOG_FILE=/u01/logs/fullbackup_PRODDB.log.${DATE_TIME}
echo >> $LOG_FILE
chmod 666 $LOG_FILE
# Show the date & time
echo --- Begin backup at `date` --- >> $LOG_FILE

export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
echo $ORACLE_HOME >> $LOG_FILE

export ORACLE_SID=PRODDB
echo $ORACLE_SID >> $LOG_FILE

$ORACLE_HOME/bin/rman @/u01/disk_rman_PRODDB.sql >> $LOG_FILE

echo --- End backup at `date` --- >> $LOG_FILE


[oracle@primaryDB u01]$ cat disk_rman_PRODDB.sql
connect target /;
run
{
allocate channel ch00 type disk ;
allocate channel ch01 type disk ;
allocate channel ch02 type disk ;
BACKUP DATABASE PLUS ARCHIVELOG;
release channel ch00;
release channel ch01;
release channel ch02;
}

-------------- Embedding SQL script in Shell Script ----------------- 

vi /u01/emp.sql

CONNECT scott/tiger
SPOOL /u01/logs/emp.lst
SET lines 200
SET pages 200
SELECT *
FROM emp;
SPOOL OFF

EXIT;


vi  get_emp.ksh

#!/bin/ksh
sqlplus /nolog @/u01/emp.sql



Comments

Popular posts from this blog

Step by Step: How to troubleshoot a slow running query in Oracle

Register Archive log file manually in standby Database

How to check UNDO tablespace usage and who is using more undo