windows部分聯機自動備份指令碼!

warehouse發表於2008-08-02

c:dbbak.bat

dbbak.bat內容如下:

sqlplus / as sysdba @ dbbak.sql

把批處理檔案dbbak.bat放到任務計劃裡或者透過at命令呼叫就可以實現自動備份db

[@more@]

--================================

select 'alter tablespace '||tablespace_name||' begin backup;' from dba_data_files;

select 'host copy '||file_name||' C:oracleproduct10.2.0oradataonline;' from dba_data_files

select 'alter tablespace '||tablespace_name||' end backup;' from dba_data_files;

dbbak.sql指令碼內容可以透過上面語句構造

dbbak.sql內容如下:

alter tablespace USERS begin backup;
alter tablespace UNDOTBS2 begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace UNDOTBS1 begin backup;
alter tablespace SYSTEM begin backup;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTUSERS01.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTUNDOTBS02.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTSYSAUX01.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTUNDOTBS01.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTSYSTEM01.DBF C:oracleproduct10.2.0oradataonline;
alter tablespace USERS end backup;
alter tablespace UNDOTBS2 end backup;
alter tablespace SYSAUX end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace SYSTEM end backup;

--===============================

一個更簡單的指令碼是:

alter database begin backup;


host copy C:ORACLEPRODUCT10.2.0ORADATATESTUSERS01.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTUNDOTBS02.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTSYSAUX01.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTUNDOTBS01.DBF C:oracleproduct10.2.0oradataonline;
host copy C:ORACLEPRODUCT10.2.0ORADATATESTSYSTEM01.DBF C:oracleproduct10.2.0oradataonline;


alter database end backup;

--===============================

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1008350/,如需轉載,請註明出處,否則將追究法律責任。

相關文章