Oracle10g热备份及恢复方法

热备份脚本:

(备份数据文件、控制文件)

set feedback off pagesize 0 heading off verify off linesize 1000 trimspool on
define dir='D:/lxc/oradata/practice_bak'
define fil='&dir/back_open_commands.sql'
define spo='&dir/back_open_results.txt'
prompt *** Spooling to &fil
set serveroutput on
spool &fil
prompt spool &spo
prompt archive log list;;
prompt alter system switch logfile;;
declare
  num number;
  cursor cur_tablespace is
    select tablespace_name from dba_tablespaces where status<>'READ ONLY';
  cursor cur_datafile (tn varchar) is
    select file_name from dba_data_files where tablespace_name=tn;
begin
  for ct in cur_tablespace loop
    select count(*) into num from dba_data_files where tablespace_name=ct.tablespace_name;
    if num>0 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 copy '||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/backup.ctl' reuse;;
prompt archive log list;;
prompt spool off;;
spool off;
@&fil

(备份归档日志)

set feedback off pagesize 0 heading off verify off linesize 1000 trimspool on
define dir='D:/lxc/oradata/practice_bak'
define fil='&dir/back_arch_commands.sql'
spool &fil
prompt alter system switch logfile;;
select 'host move '||name||' &dir' from v$archived_log
where completion_time>=trunc(sysdate)-1 and completion_time<trunc(sysdate);
spool off;
@&fil

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值