方法一:
使用crontab命令,定时执行Oracle自动备份
00 22 * * * /usr/bin/su - oracle -c "/home/oracle/FJGYZX/oraclebackup_FJGYZXDB.sh"
oraclebackup_FJGYZXDB.sh脚本的内容如下:
export ORACLE_SID=fjgyzxdb
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=American_America.ZHS16GBK
ORACLE_BACKUP_PATH=/gxhdata/dbback
BACKUPDATE=`date "+%Y%m%d%H%M%S"`
LOGFILE=${ORACLE_BACKUP_PATH}/dbbak_${BACKUPDATE}.log
BACKUPFILE=${ORACLE_BACKUP_PATH}/${ORACLE_SID}_${BACKUPDATE}.dmp
echo "-----------------------Backup Start----------------------" > ${LOGFILE}
echo "backup start time:" `date +%Y-%m-%d_%H:%M:%S` >> ${LOGFILE}
/oracle/product/11.1.0/db_1/bin/exp