ITPub博客

首页 > Linux操作系统 > Linux操作系统 > windows和unix平台下Oracle冷备份脚本

windows和unix平台下Oracle冷备份脚本

原创 Linux操作系统 作者:rongshiyuan 时间:2012-05-24 20:25:07 0 删除 编辑

oracle_coldbackup_window.sql:

Rem unix platform--coldbackup.sql
Rem coldbackup.sql
Rem 冷备份脚本
Rem 执行该脚本必须保证数据库处于归档模式
Rem sqlplus '/as sysdba' @coldbackup

Remark 设置SQL*Plus环境变量
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200

Remark 设置用户变量
define dir = '/opt/oracle/oradata_backup/cold_backup'
define cmdfile = './oracle_cold_backup_command.sql'
prompt *** spooling to &cmdfile

Remark 创建包含备份命令的脚本文件
spool &cmdfile
select 'host cp ' || name || ' &dir' from v$datafile order by 1;
select 'host cp ' || member || ' &dir' from v$logfile order by 1;
select 'host cp ' || name || ' &dir' from v$controlfile order by 1;
select 'host cp ' || name || ' &dir' from v$tempfile order by 1;
spool off;

Remark 关闭数据库
shutdown immediate;

Remark 运行上面生成的脚本文件
@&cmdfile

Remark 重新启动数据库
startup;

Remark 重新设置SQL*Plus环境变量
set feedback on heading on verify on trimspool on pagesize 14

 

oracle_coldbackup_unix.sql:

Rem unix platform--coldbackup.sql
Rem coldbackup.sql
Rem 冷备份脚本
Rem 执行该脚本必须保证数据库处于归档模式
Rem sqlplus '/as sysdba' @coldbackup

Remark 设置SQL*Plus环境变量
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200

Remark 设置用户变量
define dir = '/opt/oracle/oradata_backup/cold_backup'
define cmdfile = './oracle_cold_backup_command.sql'
prompt *** spooling to &cmdfile

Remark 创建包含备份命令的脚本文件
spool &cmdfile
select 'host cp ' || name || ' &dir' from v$datafile order by 1;
select 'host cp ' || member || ' &dir' from v$logfile order by 1;
select 'host cp ' || name || ' &dir' from v$controlfile order by 1;
select 'host cp ' || name || ' &dir' from v$tempfile order by 1;
spool off;

Remark 关闭数据库
shutdown immediate;

Remark 运行上面生成的脚本文件
@&cmdfile

Remark 重新启动数据库
startup;

Remark 重新设置SQL*Plus环境变量
set feedback on heading on verify on trimspool on pagesize 14

 

 

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

请登录后发表评论 登录
全部评论

注册时间:2009-11-24

  • 博文量
    798
  • 访问量
    3144140