2008. 10. 8. 15:27

cron에 hot backup 수행방법

hot.sh
# @(#)local.profile 1.8 99/03/26 SMI
umask 022
stty istrip
export ORACLE_BASE=/u01/ora901
export ORACLE_HOME=/u01/ora901
export ORACLE_SID=ORA901
export ORACLE_OWNER=ora901
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export NLS_LANG=American_America.KO16KSC5601
export PATH=$PATH:.:$ORACLE_HOME/bin:/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:/bin:/etc
export EDITOR=vi
/u01/ora901/bin/sqlplus /nolog @/u01/ora901/hot.sql
*********************************************************************

*********************************************************************
hot.sql
connect / as sysdba
set echo on
spool backup.log
rem Starting Hot Backup
!echo 'ORACLE_SID='$ORACLE_SID
!date
archive log list
rem Backup system tablespace
alter tablespace users begin backup;
!date
!cp  /u02/ora901_data/oradata/ORA901/users01.dbf /u02/ora901_data/oradata/ORA901/users01.bak
alter tablespace users end backup;
spool off
exit
*********************************************************************

blade:/var/spool/cron/crontabs #
25 19 * * * su - ora901 -c /u01/ora901/hot.sh
crontab -e가 안될경우
export EDITOR=vi 를 해주시면 됩니다.
환경변수에 디폴트 에디터가 vi로 설정이 되어있지 않아서 이런 문제가 발생합니다.
 
출처 : http://blog.empas.com/myungho/3957282