Oracle 的手動冷備份

來源:互聯網
上載者:User

使用指令碼手工備份資料庫的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

待指令碼執行完成後,該次冷備完成。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.