oracle技术手册供初学者

源代码在线查看: backup.sh

软件大小: 761 K
上传用户: ll122644144
关键词: oracle 技术手册 初学者
下载地址: 免注册下载 普通下载 VIP

相关代码

				#!/bin/bash								#========================================================#				#    如果脚本用于crontab,下面Oracle环境变量必须设置     #				#========================================================#				ORACLE_BASE=/opt/oracle				ORACLE_HOME=$ORACLE_BASE/product/8.1.7				ORACLE_SID=oradb6				ORACLE_TERM=ansi				ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data				NLS_LANG=American_America.ZHS16GBK				NLS_DATE_FORMAT=YYYYMMDDHH24MISS				LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH				TMPDIR=/var/tmp				PATH=$PATH:$ORACLE_HOME/bin				export ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_TERM ORA_NLS33 NLS_LANG 				export NLS_DATE_FORMAT LD_LIBRARY_PATH TMPDIR PATH				#========================================================#								BACKUPDIR=/oradata/backup; export BACKUPDIR				USER_PASSWD=dbuser/oracle								RESULTFILE=/export/home/oracle/log/result.log								cd $BACKUPDIR								exp $USER_PASSWD log=$(date '+%Y%m%d').log file=$(date '+%Y%m%d').dmp owner=dbuser buffer=4096000 rows=n				if [ $? != 0 ]				then				    echo "`date` backup exp fail" >> $RESULTFILE				    exit				fi								rm -f tables.txt				sqlplus -s $USER_PASSWD 				set heading off;				set term off;				set echo off;				set pagesize 0;				set linesize 1000;				set trimspool on;				set trimout on;				set feedback off;				set colsep |;				spool tables.txt;				select table_name from user_tables;				spool off;				exit;				EOF								for table in $(cat tables.txt)				do				    exp $USER_PASSWD log=${table}_$(date '+%Y%m%d').log file=${table}_$(date '+%Y%m%d').dmp tables=$table direct=y				    if [ $? != 0 ]				    then				        echo "`date` backup exp $table fail" >> $RESULTFILE				        exit				    fi				done								compress -f *.dmp								echo "`date` backup succeed" >> $RESULTFILE							

相关资源