整庫(whole)備份-一致性整庫備份

LuiseDalian發表於2014-04-29

備份的分類:

n  一致性備份(冷備份)

n  非一致性備份(熱備份/聯機備份)

 

整個庫的備份(可以是一致性的,也可以是非一致性的)

表空間的備份(只能是非一致性的)

1.1 一致性整庫備份(whole

--1. 確定控制檔案

sys@TESTDB11>col name for a80

sys@TESTDB11>select name from v$controlfile;

 

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/TestDB11/control01.ctl

/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl

 

--2. 確定資料檔案

sys@TESTDB11>select name from v$datafile;

 

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/TestDB11/system01.dbf

/u01/app/oracle/oradata/TestDB11/sysaux01.dbf

/u01/app/oracle/oradata/TestDB11/undotbs01.dbf

/u01/app/oracle/oradata/TestDB11/users01.dbf

/u01/app/oracle/oradata/TestDB11/example01.dbf

/u01/app/oracle/oradata/TestDB11/rotbs01.dbf

 

6 rows selected.

 

--確定一下需要備份的檔案的大小

[oracle@S1011:/backup/consistent_whole]$ du -h /u01/app/oracle/oradata/TestDB11/

 2.3G   /u01/app/oracle/oradata/TestDB11

 

--3. 建立如下的目錄結構並改變它的所有者和相應的許可權

[oracle@S1011:/]$ mkdir -p /pooldisk02/backup01/consistent

[oracle@S1011:/]$ chown  -R oralce:onstall /pooldisk02

[oracle@S1011:/]$ chmod  -R /pooldisk02

 

/*******    建立備份指令碼/export/home/oracle/backup_script/backup01.sql   ******/

set head off

set feedback off

set verify off

define backup_dir='/pooldisk02/backup01/consistent/'

define script_dir='/tmp'

 

spool &script_dir/backup.sql

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

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

spool off

 

--shutdown instance

shutdown immediate;

@&script_dir/backup.sql

startup;

 

undefine backup_dir

undefine script_dir

set head on

set feedback on

set verify on

/*******    建立備份指令碼/export/home/oracle/backup_script/backup01.sql 結束******/

 

--執行指令碼/export/home/oracle/backup_script/backup01.sql

sys@TESTDB11>@backup_script/backup01.sql

 

!cp /u01/app/oracle/oradata/TestDB11/control01.ctl /backup/consistent/

!cp /u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl /backup/consistent/

 

!cp /oradata/TestDB11/system01.dbf /backup/consistent/

!cp /oradata/TestDB11/sysaux01.dbf /backup/consistent/

!cp /oradata/TestDB11/undotbs01.dbf /backup/consistent/

!cp /oradata/TestDB11/users01.dbf /backup/consistent/

!cp /oradata/TestDB11/example01.dbf /backup/consistent/

!cp /oradata/TestDB11/newundotbs01.dbf /backup/consistent/

Database closed.

Database dismounted.

ORACLE instance shut down.

 

 

 

 

 

 

 

 

ORACLE instance started.

 

Total System Global Area  855982080 bytes

Fixed Size                  2230792 bytes

Variable Size             641730040 bytes

Database Buffers          209715200 bytes

Redo Buffers                2306048 bytes

Database mounted.

Database opened.

 

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

相關文章