分类: LINUX
2011-10-24 17:08:42
一 .在windows的计划任务中定时运行rman脚本
打开记事本,加入以下内容:
rman.exe cmdfile=e:/rman_bak_database.sql >> d:/log.txt
另存为rmanbak_database.bat。其中rman_bak_database.sql的文件内容在下文中会提到。“>> d:/log.txt”把日志追加到d:/log.txt。
文件 rman_bak_database.sql的内容:
# script:bakup.rcv
# creater:xieyunchao
# date:5.8.2003
# desc:backup all database datafile in archive with rman
# connect database
#connect rcvcat rman/rman@back;
# start backup database
connect target sys/admin@192.168.1.150_demo
run{
allocate channel c1 type disk;
backup full tag 'dbfull4' format 'd:backupfull%u_%s_%p' database
include current controlfile;
sql 'alter system archive log current';
release channel c1;
}
脚本写完了,下面的内容就是把rmanbak_database.bat添加到windows计划任务中了:
开始--运行--输入"control",找到“计划任务”--添加计划任务--下一步--浏览,找到rmanbak_database.bat,选定执行脚本的频率(每天或每周),ok.
二,用linux的例行性命令at或crontab定时运行rman脚本。
先写好脚本rman_bak_database.sh 、rman_begin.sh,记住要把这两个文件的权限设置成可执行的。
rman_begin.sh的内容如下:
/u01/app/oracle/oracle/product/10.2.0/db_1/bin/rman cmdfile=/home/oracle/rmanbak/rman_bak_database.sh >> /home/oracle/rmanbak/rman.log
rman_bak_database.sh的内容如下:
# script:bakup.rcv
# creater:xieyunchao
# date:5.8.2003
# desc:backup all database datafile in archive with rman
# connect database
#connect rcvcat rman/rman@back;
# start backup database
connect target sys/admin@192.168.1.150:1521/demo
run{
allocate channel c1 type disk;
backup full tag 'dbfull4' format 'd:backupfull%u_%s_%p' database
include current controlfile;
sql 'alter system archive log current';
release channel c1;
}
下面该用at命令运行rman_begin.sh脚本了:
[oracle@ora rmanbak]$ at now +1 minutes
at> /home/oracle/rmanbak/rman_begin.sh
at>
上面的命令在一分钟后执行 /home/oracle/rmanbak/rman_begin.sh脚本,
crontab命令可以周期性的运行脚本,运行脚本时最好要加上绝对路径如:/u01/app/oracle/oracle/product /10.2.0/db_1/bin/rman cmdfile=/home/oracle/rmanbak/rman_bak_database.sh 不然会提示找不到rman命令。