Home  >  Article  >  Database  >  Linux下Oracle的自动备份(针对Oracle用户)

Linux下Oracle的自动备份(针对Oracle用户)

WBOY
WBOYOriginal
2016-06-07 17:05:00945browse

1、建立Oracle用户的一个crontabsu - root crontab -u oracle -l*/5 * * * * /home/oracle/oracle_backup.sh(每5分钟执行一次该

1、建立Oracle用户的一个crontab
su - root

crontab -u oracle -l
*/5 * * * * /home/oracle/oracle_backup.sh
(每5分钟执行一次该shell文件,这里是位了测试方便,具体什么时间请自行修改。)

2、建立一个shell文件
cd /home/oracle/
vi oracle_back.sh
内容如下:
#!/bin/bash
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH

rq=`date +%Y%m%d_%H%M`
/home/oracle/oracle/product/10.2.0/db_1/bin/exp scott/tiger owner=scott file=/home/oracle/backup/data_$rq.dmp log=/home/oracle/backup/log/log_backup_$rq.log

注意:(1)这里的export所输出的内容要写在该shell里面,因为crontab不能读取用户的环境。
(2)一般来说,执行定期的命令不要用root权限。这个只是个建议。
(3)crontab命令一般要运行起来需几分钟,请等待下。改了后,发现没什么变化,,这个是正常的,等待一下就可。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn