您在这里:首页 > 学员专区 > 技术文章
Oracle视频
Oracle
CUUG课程

一致性备份(冷备份)

 

1、编写生成备份脚本的脚本

#cold backcup

remark set sql*plus variable to manipulate output         //注释

set feedback off heading off verify  off trimspool off  echo off time off

set pagesize 0  linesize 200

remark set sql*plus user variable used  in this script                //注释

define bakdir='/disk1/backup/anny/cold_bak'                             //备份文件的存放位置

define bakscp='/disk1/backup/anny/cold_bak/cold_cmd.sql'               //执行备份的脚本,自动生成

prompt *** Spooling to &bakscp                        //输出提示语

remark  create a command file with  file backup commands

spool &bakscp

select 'host cp '|| name ||' &bakdir ' from v$datafile order by 1;

select 'host cp '|| name ||' &bakdir ' from v$controlfile order by 1;

spool off;

remark   shutdown the database cleanly

shutdown immediate; ——冷备份需要关库执行

remark run the copy file commands form the operating system

@&bakscp

remark start the database again

startup;

 

2、执行该脚本生成了一个脚本cold_cmd.sql,并执行该脚本进行冷备份

SQL> conn /as sysdba

Connected.

SQL> @/export/home/oracle/sqlplus/anny_cold_bak

SP2-0734: unknown command beginning "cold backc..." - rest of line ignored.

*** Spooling to /disk1/backup/anny/cold_bak/cold_cmd.sql        ——一下是脚本内容

host cp /u01/app/oracle/oradata/anny/index01.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/lx01.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/lx02.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/lx03.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/lx04.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/sysaux01.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/system01.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/text01.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/undotbs01.dbf /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/user01.dbf /disk1/backup/anny/cold_bak

host cp /disk1/oradata/anny/control02.ctl /disk1/backup/anny/cold_bak

host cp /disk2/oradata/anny/control03.ctl /disk1/backup/anny/cold_bak

host cp /u01/app/oracle/oradata/anny/control01.ctl /disk1/backup/anny/cold_bak

Database closed.

Database dismounted.

ORACLE instance shut down.

ORACLE instance started.

Total System Global Area  314572800 bytes

Fixed Size                  1279964 bytes

Variable Size              58722340 bytes

Database Buffers          251658240 bytes

Redo Buffers                2912256 bytes

Database mounted.

Database opened.

相关文章 [上一篇] 手工备份的概述
010-88589926(88587026)
CUUG热门培训课程
Oracle DBA就业培训
CUUG名师
网络课程
技术沙龙
最新动态

总机:(010)-88589926,88589826,88587026 QQ讨论群:243729577 182441349 邮箱:cuug_bj@cuug.com
通信地址:北京市海淀区紫竹院路98号北京化工大学科技园609室(CUUG)邮政编码:100089 
中国UNIX用户协会 Copyright 2010  ALL Rights Reserved 北京神脑资讯技术有限公司
京ICP备11008061号  京公网安备110108006275号