oracle服务器自动备份
1、
$sqlplus/nolog $connsys/assysdba sql>createdirectoryexpdataas'/home/oracle/oraclebak'; Directorycreated. sql>grantread,writeondirectoryexpdatatopublic; sql>exit
2、
$mkdir /home/oracle/oraclebak
3、创建备份角本,给执行权限
----------------------
#!/bin/sh exportORACLE_BASE=/home/oracle/app/oracle exportORACLE_HOME=$ORACLE_BASE/db11g exportORACLE_SID=X exportPATH=$PATH:$HOME/bin:$ORACLE_HOME/bin exportDATA_DIR=/home/oracle/oraclebak exportDEL_TIME=`date-d"5daysago"+%Y%m%d` exportBAKUP_TIME=`date+%Y%m%d%H%M%S` echo"Startingbakup..." echo"Bakupfilepath$DATA_DIR/$BAKUPTIME.dmp" expdpsystem/'密码'directory=expdatadumpfile=$BAKUP_TIME.dmpfull=ylogfile=$BAKUP_TIME.log echo"Deletethefilebakupbefore5days..." rm-rf$DATA_DIR/$DEL_TIME*.dmp$DATA_DIR/$DELTIME*.log echo"Deletethefilebakupsuccessfully."
4、
$crontab-e
#!/bin/sh 003***/home/oracle/orale.bak.sh