找一份可用的自动冷备份数据库文件的脚本文件(100分相送)

leecooper0918 2003-11-27 10:06:44

OS: Linux Advanced Server 2.1
DB: Oracle 8.1.7.0

大致思路:
1. 关数据前先清掉无用的SESSION(这段脚本我写好了)

2. 正常关闭数据库(SHUTDOWN NORMAL)
3. 如果数据库不能正常关闭,从日志文件尾部寻找特征串
"ALTER DATABASE CLOSE NORMAL"
如果发现存在,则进行冷备份,否则不进行操作.

各位高手帮我看看,或者提供一个好的Solution.

附件:

1.Killsession.sql

create or replace procedure KillSess
is

i_sid number;
i_serial number;

cursor cur_sess is
select sid, serial#
from v$session
where status = 'INACTIVE'
and type!= 'BACKGROUD';
Begin
open cur_sess;
loop
fetch cur_sess into i_sid,i_serial;
if cur_sess%notfound then
exit;
end if;

execute immediate 'alter system kill session ''' || i_sid ||','
|| i_serial ||'''';
end loop;
close cur_sess;
End;
/

2. autoshut.sql
-- This script file is an assistant file with CronTab
-- function: kill all non-background and inactive processes

execute killsess;
alter system checkpoint;
shutdown normal;
exit;

3. nightbak.sh
# crontab:
# 30 21 * * 1-5 sh /vld/dbbackup/nightbak.sh
cat /dbbackup/cronjobs/syspw |sqlplus sys @autoshut.sql

tail alert_ora817.log |grep 'Completed: ALTER DATABASE CLOSE NORMAL' 1>temp
if test -s temp;
then
# echo 'found'
cd /oracle/ora817/oradata
cp *.dbf ./backup
cp *.ctl /backup/ctlfile
else
# echo 'not found'
fi

...全文
43 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevin218 2003-12-01
  • 打赏
  • 举报
回复
点击管理就可以进行啦

对了,能不能把你找到的给帖出来,让大家伙长点见识呢
谢谢!
daydayupliq 2003-11-28
  • 打赏
  • 举报
回复


回复 | 推荐 | 收藏 | 专题 | 公告 | 管理 | 保存 | 回复通知 | 关闭窗口


中的》管理》
leecooper0918 2003-11-28
  • 打赏
  • 举报
回复
呵呵,楼上的知道怎么 结贴吗? 找半天我没找到.
lynx1111 2003-11-28
  • 打赏
  • 举报
回复
散分?
leecooper0918 2003-11-28
  • 打赏
  • 举报
回复

自己找到了一份,呵呵。
不过里面没有错误处理的部分,还得自己加.

暂时先结贴吧。

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧