ORACLE定时备份

windows下运行脚本

echo off
f:
set dirName=%date:~0,4%%date:~5,2%%date:~8,2%
mkdir F:\compayData\%dirName%
set ORACEL_HOME=d:\oracle\product\10.2.0\db_1
cd F:\compayData\%dirName%
d:\oracle\product\10.2.0\db_1\bin\exp chargedba/comsys@orcl file=F:\compayData\%dirName%\chargedba.dmp owner=chargedba
d:\oracle\product\10.2.0\db_1\bin\exp paydba/comsys@orcl file=F:\compayData\%dirName%\paydba.dmp owner=paydba

linux下运行脚本

#!/bin/sh
cd /opt/backupDatabase
export dirName=`date --date=today +%Y%m%d`
mkdir $dirName
export ORACLE_HOME=/DBSoftware/app/oracle/product/10.2.0/db_1
$ORACLE_HOME/bin/exp chargedba/comsys@orcl file=/opt/backupDatabase/$dirName/chargedba.dmp owner=chargedba
$ORACLE_HOME/bin/exp paydba/comsys@orcl file=/opt/backupDatabase/$dirName/paydba.dmp owner=paydba

把此脚本放入:

/etc/crond.daily

之后授权:

chmod 777 **.sh

设置执行时间:

vi /etc/crontab

 

o 2 * * * root run-parts /etc/cron.daily  //每日两点钟执行备份

你可能感兴趣的:(oracle)