Oracle 的手动冷备份

2014-11-24 18:53:57 · 作者: · 浏览: 0

使用脚本手工备份数据库的datafile,redo log file,control file到指定目录


OS的版本:


数据库版本:


SQL> select * from v$version;


Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production


PL/SQL Release 11.2.0.1.0 - Production


CORE 11.2.0.1.0 Production


TNS for Linux: Version 11.2.0.1.0 - Production


NLSRTL Version 11.2.0.1.0 - Production


在/tmp 目录下编写脚本


-- 设置sqlplus环境


set feedback off heading off verify off trimspool off


set pagesize 0 linesize 200


--指定备份文件存放在哪个目录


define dir='/tmp/wb'


--告知数据库调用何处的脚本进行备份


define ws='/tmp/ws.sql'


--把以下的select输出存放在ws指定的文件中


spool &ws


select '!cp ' ||name || ' &dir' from v$datafile;


select '!cp ' ||name || ' &dir' from v$controlfile;


select '!cp ' ||name || ' &dir' from v$tempfile;


select '!cp ' ||member || ' &dir' from v$logfile;


spool off


--因为是冷备,所以关闭数据库。注意是干净地关闭数据库,不是abort。


shutdown immediate


--调用spool输出在ws中的脚本。此过程是对三类文件的拷贝。文件大小不同,耗时会有不同


@&ws


startup


set feedback on heading on verify on trimspool on


待脚本执行完成后,该次冷备完成。