ITPub博客

首页 > 数据库 > Oracle > redhat下通过rman自动备份db!

redhat下通过rman自动备份db!

原创 Oracle 作者:warehouse 时间:2008-08-02 21:39:04 0 删除 编辑

仅仅是思路和过程,根据自己的需求调整:

1 cp /home/oracle/.bash_profile dbbak.sh

之所以要拷贝这个文件,是因为它是oracle用户的环境变量文件,里面包含了oracle用户所需要的所有环境变量

2. 在dbbak.sh文件中加入如下语句:

rman target sys/password@tns cmdfile=/home/oracle/dbbak.sql

3. 编写dbbak.sql如下:

backup tablespace 'TEST';这里只是用来测试!

4. chmod +x dbbak.sh

5. 利用crontab来调用dbbak.sh脚本实现自动备份db,假如想每天晚上21:38分自动备份db,那么可以通过crontab -e来编辑root用户的自动定时任务:

[root@xys oracle]# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.3386 installed on Sat Aug 2 21:36:35 2008)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
38 21 * * * /home/oracle/dbbak.sh

6. 有关crontab的使用可以参考

http://blog.chinaunix.net/u/31547/showart_438018.html

[@more@]

dbbak.sh内容如下:

[oracle@xys oracle]$ more dbbak.sh
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=TEST
#export NLS_LANG=american.america.WE8ISO8859P1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

export DBCA_RAW_CONFIG=$ORACLE_BASE/oradata/test/test_raw.conf

export LC_CTYPE=en_US.UTF-8

LANG=zh
LC_ALL=zh
export LANG LC_ALL
#export DISPLAY=192.168.0.252:0.0
alias sqlplus='/usr/local/rlwrap/bin/rlwrap sqlplus'

rman target sys/password@tns cmdfile=/home/oracle/dbbak.sql

--============================================

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/19602/viewspace-1008364/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-07

  • 博文量
    717
  • 访问量
    5366325