备份脚本如下:
#!/bin/bash export ORACLE_BASE=/data/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=orcl export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH source ~/.bash_profile cd /disk01/db_back rm -f `date +%w`.dmp rm -f `date +%w`.log expdp \‘sys/[email protected] as sysdba\‘ directory=ora_back dumpfile=`date +%w`.dmp logfile=`date +%w`.log schemas=xxx,xxx123 |
crontab任务如下:
[[email protected] scripts]$ crontab -l
* 4 * * 1,4 sh /home/oracle/scripts/expdp.sh ----即 每周1 周4 执行备份脚本