oracle安装账号已被锁定Oracle冷备和热备脚本

Oracle冷备和热备脚本

 

冷备脚本:

 

set feedback offset heading offset verify  offset trimspool offset echo offset time offset timing offset pagesize 0set linesize 200define dir='/backup/cold/mike';define diroutmike='/u01/scripts/coldscr/mikecoldout.sql';spool &diroutmikeselect '!cp '||name||' &dir' from v$datafile order by file#;select '!cp '||name||' &dir' from v$controlfile;spool off;shutdown immediate;@&diroutmikestartup;

 

 

以上脚本放在/u01/scripts/coldscr/mikecold.sql

 

在数据库运行时可以运行此脚本来冷备。

 

热备脚本:

 

set feedback off set pagesize 0 set heading off set verify off set linesize 100 set trimspool on set echo off set time off set timing offundefine mikedirundefine mikescpdefine mikedir='/backup/hot'define mikescp='/u01/scripts/hotscr/mikehotout.sql'declare        cursor cur_tablespace is select tablespace_name from dba_tablespaces where status <> 'READ ONLY' and contents not like '%TEMP%';        cursor cur_datafile(tn varchar2) is select file_name from dba_data_files where tablespace_name=tn;begin        for ct in cur_tablespace loop                dbms_output.put_line('alter tablespace '||ct.tablespace_name||' begin backup;')oracle账号;                        for cd in cur_datafile(ct.tablespace_name) loop                                dbms_output.put_line('! cp '||cd.file_name||' &mikedir');                        end loop;                dbms_output.put_line('alter tablespace '||ct.tablespace_name||' end backup;');        end loop;end;/

 

以上脚本放在/u01/scripts/hotscr/mikehot.sql

 

在数据库运行时可以运行此脚本来热备。

此条目发表在oracle metalink账号分类目录,贴了标签。将固定链接加入收藏夹。