Backup & Recovery的分類
Backup 分為 Closed 及 Open,Recovery 則分為 Complete 及 Incomplete。- Backup
- Closed : Noarchivelog Mode 適用,資料庫Shutdown
- Close the controlfile
- Close the online logfile
- Close the datafile
- Open : 只有 Archivelog Mode 可以,資料庫Open
- Alter database backup control file to ...
- Archive the online logfile
- Alter tablespace .... begin backup - copy the datafiles - alter tablespace .... end backup
- Restore & recover
- Complete
- Take the damaged file offline
- Restore it
- Recover it
- Bring it online
- Incomplete
- Mount the database
- Restore all datafiles
- Recover database until ...
- Open resetlogs
Noarchivelog Mode Backup
此模式只能選用Closed Backup,備份前,需關閉資料庫,將檔案使用作業系統的命令來複製。但複製前必須確認所複製檔案沒有漏掉。可在資料庫關閉前使用下列命令來產生完整複製的指令。
select 'cp ' || name || ' /home/oracle/bkup' from v$controlfile ; select 'cp ' || name || ' /home/oracle/bkup' from v$datafile ; select 'cp ' || name || ' /home/oracle/bkup' from v$tempfile ; select 'cp ' || member || ' /home/oracle/bkup' from v$logfile ;
Archivelog Mode Backup
User-Managed Backup 主要包含CONTROLFILE 和 DATAFILE 的備份要先確定資料庫屬於 ARCHIVELOG MODE
- 以下範例展示在 Archivelog Mode下進行的User-managed backup
- 建立暫時的TABLESPACE create tablespace ex181 datafile '/oracle/app/oracle/oradata/sedb/ex181.dbf' size 10m extent management local segment space management auto;
- 在新的表格空間建立新TABLE create table t1 (c11 date) tablespace ex181;
- 將TABLESPACE 設定為 BACKUP MODE alter tablespace ex181 begin backup ;
- Backup datafile [oracle@db01 bkup]$ cp /oracle/app/oracle/oradata/sedb/ex181.dbf /home/oracle/bkup/ex181.dbf
- 將TABLESPACE 設定結束 BACKUP MODE alter tablespace ex181 end backup;
- 對CONTROLFILE做BINARY BACKUP alter database backup controlfile to '/home/oracle/bkup/controlfile01.bin';
- 對CONTROLFILE做Logical BACKUP alter database backup controlfile to trace as '/home/oracle/bkup/controlfile01.log';