Oracle物理热备份脚本(ZT)

http://hi.baidu.com/edeed/blog/item/0fb9526684b6d327ab184c8c.html

Rem 热备份脚本
Rem 执行该脚本必须保证数据库处于归档模式
Rem 张乐奕 2004-3-24

Rem
Rem 设置SQL*Plus环境参数
Rem

set feedback off
set pagesize 0
set heading off
set verify off
set linesize 100
set trimspool on

Rem 设置需要使用的SQL*Plus用户变量
Rem for Windows
define dir = 'E:\oracle\oradata.bak\hotbak'
define fil = '.\open_backup_commands.sql'
define spo = '&dir\open_backup_output.lst'
define cpy = 'copy'

Rem 设置Linux环境中的SQL*Plus用户变量
Rem define dir = '/oradata/PRACTICE/backup/user/ch05'
Rem define fil = '/tmp/open_backup_commands.sql'
Rem define spo = '&dir/open_backup_output.lst'
Rem define cpy = 'cp'

prompt *** Spooling to &fil

Rem 产生备份命令脚本文件

set serveroutput on
spool &fil
prompt spool &spo
prompt archive log list;;
prompt alter system switch logfile;;
prompt alter system archive log all;;

DECLARE
CURSOR cur_tablespace IS
SELECT tablespace_name
FROM dba_tablespaces;

CURSOR cur_datafile (tn VARCHAR) IS
SELECT file_name
FROM dba_data_files
WHERE tablespace_name = tn;
BEGIN
FOR ct IN cur_tablespace LOOP
IF ct.tablespace_name!='TEMP' then
dbms_output.put_line ('alter tablespace '||ct.tablespace_name||' begin backup;');
FOR cd IN cur_datafile (ct.tablespace_name) LOOP
dbms_output.put_line ('host &cpy '||cd.file_name||' &dir');
END LOOP;
dbms_output.put_line ('alter tablespace '||ct.tablespace_name||' end backup;');
end if;
END LOOP;

END;
/

prompt alter system switch logfile;;
prompt alter database backup controlfile to '&dir\backcontrol.ctl' REUSE;;

prompt archive log list;;
prompt spool off
spool off;

Rem 执行生成的脚本文件

@&fil

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

转载于:http://blog.itpub.net/17252115/viewspace-730893/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值