1.创建一个脚本schema_exp.sh
[oracle@localhost ~]$ ls
afiedt.buf hot_backup.sh rman_backup.sh sqlnet.log
cold_backup.sh schema_exp.sh
2.schema_exp.sh代码:
#!/bin/bash
log_file=/oracle/admin/$ORACLE_SID/full_exp_$ORACLE_SID.log
exp_arguments="userid=system/oracle buffer=10485760 owner=$1"
if [ $2 ]
then
exp_arguments="$exp_arguments file=$2"
else
exp_arguments="$exp_arguments file=/oracle/bakup/luoji/"$ORACLE_SID"_full_export.dmp"
fi
echo "Beginning full db export..." > $log_file
echo "Exporting with following arguments: $exp_arguments">> $log_file
exp $exp_arguments >> $log_file 2>&1
echo "Export finished." >> $log_file
date >> $log_file
exp_result=$?
if [ exp_result!=0 ]
then
mail -s "Errors in exporting $ORACLE_SID." zgk_baqi@126.com< $log_file
fi
3.执行脚本
[oracle@localhost ~]$ chmod +x schema_exp.sh
[oracle@localhost ~]$ ./schema_exp.sh zgk 导出zgk用户下的数据