您的位置:首页 > 数据库 > Oracle

oracle技术之oracle一致性备份(冷备份)

2013-05-20 16:28 302 查看
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.

oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息