Oracle 的手動冷備份 |
發布時間: 2012/7/10 17:26:16 |
使用腳本手工備份數據庫的datafile,redo log file,control file到指定目錄 OS的版本: [Oracle@sam tmp]$ cat /proc/version Linux version 2.6.18-274.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Fri Jul 22 04:49:12 EDT 2011 數據庫版本: 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 待腳本執行完成后,該次冷備完成 本文出自:億恩科技【www.artduck.net】 |