############crontab设置###########
30 1 * * * /home/oracle/backup/backupsh/expfull.sh
############expfull.sh设置###########
/home/oracle/backup/backupsh/tables.sh
cat /home/oracle/backup/backupsh/exp_temp.parfile > /home/oracle/backup/backupsh/expfull.parfile
cat /home/oracle/backup/backupsh/tables.lst >> /home/oracle/backup/backupsh/expfull.parfile
/home/oracle/backup/backupsh/start_exp.sh
############start_exp.sh设置###########
source /home/oracle/.bash_profile
BACK_HOME=/home/oracle/backup
BACK_DEST=$BACK_HOME/expfull
SH_HOME=/home/oracle/backup/backupsh
export $BACK_HOME
export $BACK_DEST
export $SH_HOME
DBA="[email protected]"
DATE=`date +"%m%d:%H.%M"`
IP=""
exp_log_file=$SH_HOME/expfull.log
MAIL_COMMAND=/bin/mailx
$ORACLE_HOME/bin/exp parfile=$SH_HOME/expfull.parfile;
cat $exp_log_file |$MAIL_COMMAND -s "exp backup message from $IP $DATE " $DBA
###########exp_temp.parfile##############
userid=xzsp/xzsp
filesize=2048M
file=(/home/oracle/backup/fulldmp1.dmp,
/home/oracle/backup/fulldmp2.dmp,
/home/oracle/backup/fulldmp3.dmp,
/home/oracle/backup/fulldmp4.dmp)
rows=y
log=/home/oracle/backup/backupsh/expfull.log
compress=n
buffer=40960000
direct=y
##############tables.sh###################
sqlplus -S "/ as sysdba" >/dev/null <<EOF
set echo off
set termout off
set feedback off
set heading off
set linesize 120
set pagesize 0
select to_char(sysdate,‘‘‘yyyy-mm-dd hh:mm:ss‘‘‘) from dual;
spool /home/oracle/backup/backupsh/tables.lst
SELECT ‘tables=(‘ || CHR(10) FROM DUAL;
SELECT owner || ‘.‘ || table_name || ‘,‘ || CHR(10)
FROM dba_tables
WHERE owner NOT IN (‘SYS‘,‘SYSTEM‘,‘CTXSYS‘,‘ORDSYS‘,‘MDSYS‘)
AND table_name NOT IN
(‘SMS_LOG‘,‘SMS_RESPREPT_ERROR‘,‘SMS_STATUSREPT‘,‘PUSH_USER_INFO_LOG‘)
ORDER BY owner;
SELECT ‘SYS.DUAL‘ FROM DUAL;
SELECT ‘)‘ FROM DUAL;
spool off
EOF
说明:ORACLE10G 以后解决这个问题更方便,使用exclude include。用法如下:
EXCLUDE = object_type[:name_clause][,…]
INCLUDE = object_type[:name_clause][,…]
例如:
Expdp <other_paramters> SCHEMAS=XZSP EXCLUDE=SEQUENCE,INDEX,TABLE:”LIKE %EMP”
IMpdp <other_paramters> SCHEMAS=XZSP INCLUDE=FUNCTION,PACKAGE,PROCEDUGE ,TABLE:”IN (‘EMP’,’DEMP’)”
Linux下使用需要使用转义字符“\”,当然最好使用参数文件
############定义参数文件parfile.par ##############
Directory=expdir
Schemas=rman
Dumpfile=expdp_rman.dmp
Include=TABLE:”IN(‘DB’,’TS’)”
执行导出命令如下
Expdp \’/ as sysdba \’ parfile.par