Oracle冷备和热备脚本
Oracle冷备脚本: set feedback off set heading off set verify off set trimspool off set echo off set time off set timin
Oracle冷备脚本:
set feedback off
set heading off
set verify off
set trimspool off
set echo off
set time off
set timing off
set pagesize 0
set linesize 200
define dir='/backup/cold/mike';
define diroutmike='/u01/scripts/coldscr/mikecoldout.sql';
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;
以上脚本放在/u01/scripts/coldscr/mikecold.sql
在数据库运行时可以运行此脚本来冷备。
Oracle热备脚本:
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 off
undefine mikedir
undefine mikescp
define 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' a
nd 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;');
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
在数据库运行时可以运行此脚本来热备。
上一篇: php循环创建目录示例分享
推荐阅读
-
Oracle冷备和热备脚本
-
Oracle冷备----删除非系统表空间
-
Python+cx_Oracle安装及一个简单示例(归档下热备数据文件)
-
Oracle 双机热备:Oracle dataguard 和Oracle rac的区别和联系
-
keepalived的原理、LVS负载均衡之DR模式+KeepAlived双机热备架构【原理和配置】
-
MySQL 备份和恢复(三)Xtrabackup实现热备:完全备份+增量备份
-
Oracle 热备份和冷备份的区别
-
Oracle数据库双机热备服务器操作实战
-
MySQL 备份和恢复(二)基于LVM实现几乎热备
-
win平台oracle rman备份和删除dg备库归档日志脚本