오라클 hotbackup 스크립트
2010.05.12 08:36
원문 : http://www.ischo.net -- 조인상 // 시스템 엔지니어
Writer : http://www.ischo.net -- ischo // System Engineer in Replubic Of Korea
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
본문 : http://www.ischo.net -- 조인상 //시스템 엔지니어
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
오라클 hotbakcup script
1. backup.sh
ORACLE_HOME=/oracle/app/oracle/product/9.2.0
BACK_HOME=/data/backup
## oracle begin backup
$ORACLE_HOME/bin/sqlplus "/as sysdba"<<!
@/data/backup/begin.sh
#
## oracle dbf_file_cp
@/data/backup/datadbcp.sh
exit
!
chmod 755 /data/backup/health_cp.lst /data/backup/ora_engin_cp.lst
/data/backup/health_cp.lst
/data/backup/ora_engin_cp.lst
#
## oracle eng backup
$ORACLE_HOME/bin/sqlplus "/as sysdba"<<!
@/data/backup/end.sh
exit
!
#rm /data/bakcup/begin.sql
#rm /data/bakcup/dbf.lst
#rm /data/bakcup/tmp1.lst
#rm /data/bakcup/tmp2.lst
#rm /data/bakcup/tmp3.lst
#rm /data/bakcup/ora_engin.lst
#rm /data/bakcup/health.lst
2.begin.sh
spool /data/backup/tmp2.lst
select distinct 'alter tablespace ' || tablespace_name || ' begin backup;' from dba_data_files;
spool off
!grep alter /data/backup/tmp2.lst | grep -v SQL > /data/backup/begin.sql
@/data/backup/begin.sql
3. datacp.sh
spool /data/backup/tmp1.lst
select file_name from dba_data_files;
spool off
!grep -i .dbf /data/backup/tmp1.lst > /data/backup/ora_engin.lst
!grep -i .ora /data/backup/tmp1.lst > /data/backup/health.lst
!/data/backup/health_dbf_cp.sh > /data/backup/health_cp.lst
!/data/backup/ora_engin_dbf_cp.sh > /data/backup/ora_engin_cp.lst
4. end.sh
spool /data/backup/tmp3.lst
select distinct 'alter tablespace ' || tablespace_name || ' end backup;' from dba_data_files;
spool off
!grep alter /data/backup/tmp3.lst | grep -v SQL > /data/backup/end.sql
@/data/backup/end.sql
alter system switch logfile;
5. health_dbf.sh
SRC="/data/db_datafile
TRG=/backup/health
for i in `cat /data/backup/health.lst |sed 's/\/data\/db_datafile\///'` ; do
echo cp $SRC/$i $TRG/$i
done
6.ora_engin_dbf_cp.sh
SRC="/oracle/oradata
TRG=/backup/oradata
for i in `cat /data/backup/ora_engin.lst |sed 's/\/oracle\/oradata\///'` ; do
echo cp $SRC/$i $TRG/$i
done
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
오라클 hotbakcup script
1. backup.sh
ORACLE_HOME=/oracle/app/oracle/product/9.2.0
BACK_HOME=/data/backup
## oracle begin backup
$ORACLE_HOME/bin/sqlplus "/as sysdba"<<!
@/data/backup/begin.sh
#
## oracle dbf_file_cp
@/data/backup/datadbcp.sh
exit
!
chmod 755 /data/backup/health_cp.lst /data/backup/ora_engin_cp.lst
/data/backup/health_cp.lst
/data/backup/ora_engin_cp.lst
#
## oracle eng backup
$ORACLE_HOME/bin/sqlplus "/as sysdba"<<!
@/data/backup/end.sh
exit
!
#rm /data/bakcup/begin.sql
#rm /data/bakcup/dbf.lst
#rm /data/bakcup/tmp1.lst
#rm /data/bakcup/tmp2.lst
#rm /data/bakcup/tmp3.lst
#rm /data/bakcup/ora_engin.lst
#rm /data/bakcup/health.lst
2.begin.sh
spool /data/backup/tmp2.lst
select distinct 'alter tablespace ' || tablespace_name || ' begin backup;' from dba_data_files;
spool off
!grep alter /data/backup/tmp2.lst | grep -v SQL > /data/backup/begin.sql
@/data/backup/begin.sql
3. datacp.sh
spool /data/backup/tmp1.lst
select file_name from dba_data_files;
spool off
!grep -i .dbf /data/backup/tmp1.lst > /data/backup/ora_engin.lst
!grep -i .ora /data/backup/tmp1.lst > /data/backup/health.lst
!/data/backup/health_dbf_cp.sh > /data/backup/health_cp.lst
!/data/backup/ora_engin_dbf_cp.sh > /data/backup/ora_engin_cp.lst
4. end.sh
spool /data/backup/tmp3.lst
select distinct 'alter tablespace ' || tablespace_name || ' end backup;' from dba_data_files;
spool off
!grep alter /data/backup/tmp3.lst | grep -v SQL > /data/backup/end.sql
@/data/backup/end.sql
alter system switch logfile;
5. health_dbf.sh
SRC="/data/db_datafile
TRG=/backup/health
for i in `cat /data/backup/health.lst |sed 's/\/data\/db_datafile\///'` ; do
echo cp $SRC/$i $TRG/$i
done
6.ora_engin_dbf_cp.sh
SRC="/oracle/oradata
TRG=/backup/oradata
for i in `cat /data/backup/ora_engin.lst |sed 's/\/oracle\/oradata\///'` ; do
echo cp $SRC/$i $TRG/$i
done