熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

Oracle冷備和熱備腳本

2022-06-13   來源: Oracle 

  冷備腳本

  set feedback off

  set heading off

  set verify  off

  set trimspool off

  set echo off

  set time off

  set timing off

  set pagesize

  set linesize

  define dir=/backup/cold/mike;

  define diroutmike=/u/scripts/coldscr/mikecoldoutsql;

  spool &diroutmike

  select !cp ||name|| &dir from v$datafile order by file#;

  select !cp ||name|| &dir from v$controlfile;

  spool off;

  shutdown immediate;

  @&diroutmike

  startup;

  以上腳本放在/u/scripts/coldscr/mikecoldsql

  在數據庫運行時可以運行此腳本來冷備

  熱備腳本

  set feedback off

  set pagesize

  set heading off

  set verify off

  set linesize

  set trimspool on

  set echo off

  set time off

  set timing off

  undefine mikedir

  undefine mikescp

  define mikedir=/backup/hot

  define mikescp=/u/scripts/hotscr/mikehotoutsql

  declare

  cursor cur_tablespace is select tablespace_name from dba_tablespaces where status <> READ ONLY a

  nd contents not like %TEMP%;

  cursor cur_datafile(tn varchar) is select file_name from dba_data_files where tablespace_name=tn;

  begin

  for ct in cur_tablespace loop

  dbms_outputput_line(alter tablespace ||cttablespace_name|| begin backup;);

  for cd in cur_datafile(cttablespace_name) loop

  dbms_outputput_line(! cp ||cdfile_name|| &mikedir);

  end loop;

  dbms_outputput_line(alter tablespace ||cttablespace_name|| end backup;);

  end loop;

  end;

  /

  以上腳本放在/u/scripts/hotscr/mikehotsql

  在數據庫運行時可以運行此腳本來熱備


From:http://tw.wingwit.com/Article/program/Oracle/201311/18069.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.