hot 백업 쉘 스크립트

main_backup.sh

export LANG=C
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10g
export PAHT=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=testdb

touch $ORACLE_BASE/open_backup.log
echo “”
echo “set begin backup mode”
time sh $ORACLE_BASE/begin_backup.sh >> $ORACLE_BASE/open_backup.log
echo “”
echo “end begin backup mode”
echo “”
echo “start file copy”
echo “”
time sh $ORACLE_BASE/copy_back.sh >> $ORACLE_BASE/total.log
ech “end filr copy”
echo “”
echo “set end backup mode”
time sh ##/end_backup.sh >> ##/total.log
echo “complete hot backup”

begin_backup.sh

export LANG=C
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10g
export PAHT=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=testdb

sqlplus /nolog << EOF1
conn / as sysdba

set head off
set feedback off
set time off
set timing off
set echo off
spool /tmp/online.tmp
select ‘alter tablespace ‘|| tablespace_name ||’ begin backup;’ \
from dba_tablespaces \
where status=’ONLINE’ \
and contents != ‘TEMPORARY’;
spool off
!cat /tmp/online.tmp | egrep -v spool | grep -v SQL | egerp -v [2-4] > ##/begin.sh
@##/begin.sh
!sh ##/status.sh
exit EOF!

copy_backup.sh

export LANG=C
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10g
export PAHT=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=testdb
export BACKUP_DIR=/data/backup/open/

sqlplus / nolog << EOF3
conn / as sysdba
set head off
set feedback off
set time off
set timing off
set echo off
set line 200
col name for a100
spool ##/cp.tmp
select ‘mkdir /data/backup/open/’||to_char(sysdate,’RRRR-MM-DD:HH24:MI:SS’) from dual;
select ‘cp -av ‘||name||’ /data/backup/open/to_char(sysdate, ‘RRRR-MM-DD:HH24:MI:SS’) “name” from v\$datafile;
spool off

spool ##/control.tmp
alter session set nls_date_format=’RRRR-MM-DD:HH24:MI:SS’;
select ‘alter database backup controlfile to ”/data/backup/open/’||sysdate||\
 ‘/’||sysdate||’.ctl”;’ from dual;
spool off
!cat ##/cp.tmp/ | grep -v SQL > ##/cp.sh
!cat ##/control.tmp | grep -v SQL > ##/control.sql

!sh ##/cp.sh
@##/control.sql
exit
EOF3

end_backup.sh

export LANG=C
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10g
export PAHT=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=testdb

sqlplus /nolog << EOF4
conn / as sysdba

set head off
set feedback off
set time off
set timing off
set echo off
spool /tmp/online.tmp
select ‘alter tablespace ‘|| tablespace_name ||’ end backup;’ \
from dba_tablespace \
where status=’ONLINE’ \
and contenst != ‘TEMPORARY’;
spool off
!cat /tmp/online.tmp | egrep -v spool| egerp -v SQL | egerp -v [2-4] > ##/end.sh
@##/end.sh
!sh ##/status.sh
exit
EOF4

You may also like...

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다