오라클 온라인백업스크립트 구성 예
2010.05.12 08:37
원문 : http://www.ischo.net -- 조인상 // 시스템 엔지니어
Writer : http://www.ischo.net -- ischo // System Engineer in Replubic Of Korea
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
본문 : http://www.ischo.net -- 조인상 //시스템 엔지니어
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/ksh
##########################################
### backup script by SayIT Cho In-Sang
##########################################
##### datafile online backup
sqlplus '/ as sysdba' << !
## datafile backup
alter tablespace SYSTEM begin backup;
!cp -p /oradata/LMIS/system01.dbf /backup/online/LMIS
alter tablespace SYSTEM end backup;
alter tablespace UNDOTBS1 begin backup;
!cp -p /oradata/LMIS/undotbs01.dbf /backup/online/LMIS
alter tablespace UNDOTBS1 end backup;
alter tablespace INDX begin backup;
!cp -p /oradata/LMIS/indx01.dbf /backup/online/LMIS
alter tablespace INDX end backup;
alter tablespace TOOLS begin backup;
!cp -p /oradata/LMIS/tools01.dbf /backup/online/LMIS
alter tablespace TOOLS end backup;
alter tablespace USERS begin backup;
!cp -p /oradata/LMIS/users01.dbf /backup/online/LMIS
alter tablespace USERS end backup;
alter tablespace LMIS begin backup;
!cp -p /oradata/LMIS/lmis01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis02.dbf /backup/online/LMIS
alter tablespace LMIS end backup;
alter tablespace LMIS_IDX begin backup;
!cp -p /oradata/LMIS/lmis_idx01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_idx02.dbf /backup/online/LMIS
alter tablespace LMIS_IDX end backup;
alter tablespace LMIS_GIS begin backup;
!cp -p /oradata/LMIS/lmis_gis01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis02.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis03.dbf /backup/online/LMIS
alter tablespace LMIS_GIS end backup;
alter tablespace LMIS_GIS_IDX begin backup;
!cp -p /oradata/LMIS/lmis_gis_idx01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis_idx02.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis_idx03.dbf /backup/online/LMIS
alter tablespace LMIS_GIS_IDX end backup;
alter tablespace LMIS_LOB begin backup;
!cp -p /oradata/LMIS/lmis_lob01.dbf /backup/online/LMIS
alter tablespace LMIS_LOB end backup;
alter tablespace SDE begin backup;
!cp -p /oradata/LMIS/sde.dbf /backup/online/LMIS
alter tablespace SDE end backup;
alter tablespace KCSC_DAT begin backup;
!cp -p /oradata/LMIS/kcsc_dat01.dbf /backup/online/LMIS
alter tablespace KCSC_DAT end backup;
alter tablespace KCSC_IDX begin backup;
!cp -p /oradata/LMIS/kcsc_idx01.dbf /backup/online/LMIS
alter tablespace KCSC_IDX end backup;
## redo log file backup
!cp -p /oradata/LMIS/redo01.log /backup/online/LMIS
!cp -p /oradata/LMIS/redo02.log /backup/online/LMIS
!cp -p /oradata/LMIS/redo03.log /backup/online/LMIS
## control file backup
!rm /backup/control/*
alter database backup controlfile to '/backup/control/control01.ctl';
alter database backup controlfile to '/backup/control/control02.ctl';
alter database backup controlfile to '/backup/control/control03.ctl';
### init file backup
!cp -p /oracle/app/oracle/product/920/dbs/* /backup/initfile
!
위와같이 짠 스크립트를 퍼미션과 실행권한을 조정하여 cron에
등록한다.
예)
# crontab -e
30 4 * * * su - oracle -c /backup/script/onbackup.sh
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/ksh
##########################################
### backup script by SayIT Cho In-Sang
##########################################
##### datafile online backup
sqlplus '/ as sysdba' << !
## datafile backup
alter tablespace SYSTEM begin backup;
!cp -p /oradata/LMIS/system01.dbf /backup/online/LMIS
alter tablespace SYSTEM end backup;
alter tablespace UNDOTBS1 begin backup;
!cp -p /oradata/LMIS/undotbs01.dbf /backup/online/LMIS
alter tablespace UNDOTBS1 end backup;
alter tablespace INDX begin backup;
!cp -p /oradata/LMIS/indx01.dbf /backup/online/LMIS
alter tablespace INDX end backup;
alter tablespace TOOLS begin backup;
!cp -p /oradata/LMIS/tools01.dbf /backup/online/LMIS
alter tablespace TOOLS end backup;
alter tablespace USERS begin backup;
!cp -p /oradata/LMIS/users01.dbf /backup/online/LMIS
alter tablespace USERS end backup;
alter tablespace LMIS begin backup;
!cp -p /oradata/LMIS/lmis01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis02.dbf /backup/online/LMIS
alter tablespace LMIS end backup;
alter tablespace LMIS_IDX begin backup;
!cp -p /oradata/LMIS/lmis_idx01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_idx02.dbf /backup/online/LMIS
alter tablespace LMIS_IDX end backup;
alter tablespace LMIS_GIS begin backup;
!cp -p /oradata/LMIS/lmis_gis01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis02.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis03.dbf /backup/online/LMIS
alter tablespace LMIS_GIS end backup;
alter tablespace LMIS_GIS_IDX begin backup;
!cp -p /oradata/LMIS/lmis_gis_idx01.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis_idx02.dbf /backup/online/LMIS
!cp -p /oradata/LMIS/lmis_gis_idx03.dbf /backup/online/LMIS
alter tablespace LMIS_GIS_IDX end backup;
alter tablespace LMIS_LOB begin backup;
!cp -p /oradata/LMIS/lmis_lob01.dbf /backup/online/LMIS
alter tablespace LMIS_LOB end backup;
alter tablespace SDE begin backup;
!cp -p /oradata/LMIS/sde.dbf /backup/online/LMIS
alter tablespace SDE end backup;
alter tablespace KCSC_DAT begin backup;
!cp -p /oradata/LMIS/kcsc_dat01.dbf /backup/online/LMIS
alter tablespace KCSC_DAT end backup;
alter tablespace KCSC_IDX begin backup;
!cp -p /oradata/LMIS/kcsc_idx01.dbf /backup/online/LMIS
alter tablespace KCSC_IDX end backup;
## redo log file backup
!cp -p /oradata/LMIS/redo01.log /backup/online/LMIS
!cp -p /oradata/LMIS/redo02.log /backup/online/LMIS
!cp -p /oradata/LMIS/redo03.log /backup/online/LMIS
## control file backup
!rm /backup/control/*
alter database backup controlfile to '/backup/control/control01.ctl';
alter database backup controlfile to '/backup/control/control02.ctl';
alter database backup controlfile to '/backup/control/control03.ctl';
### init file backup
!cp -p /oracle/app/oracle/product/920/dbs/* /backup/initfile
!
위와같이 짠 스크립트를 퍼미션과 실행권한을 조정하여 cron에
등록한다.
예)
# crontab -e
30 4 * * * su - oracle -c /backup/script/onbackup.sh