1. 닫힌 백업( cold backup, close backup )
- database의 운영상태가 closed 된 상태에서 수행하는 백업을 의미
- 백업 시점이 모두 동일해야 함
- data file, online redo log file, control file 백업가능
- 운영중(open) 상태에서는 수행할 수 없음
- archived log mode / no archived mode 상관없음
2. 열린 백업(hot backup, begin backup, online backup)
- 닫힌 백업과 달리 DB가 운영중(open) 상태에서도 백업을 수행 가능
- archived log mode 상태에서만 수행 가능
- 많은 양의 redo log가 발생됨
- data file, control file만 백업가능(redo log file 백업 불가)
- hotbackup 할 때, 디비 offline 하면 안 됨
*노아카이브-아카이브 / 아카이브-노아카이브 모드가 바뀌면 무조건 백업을 받아야 한다.
왜냐하면 scn이 달라지기 때문이다.
cold back
백업대상확인 -> DB종료 -> 대상백업수행
1. data file 확인
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/app/oracle/oradata/testdb/system01.dbf
/app/oracle/oradata/testdb/sysaux01.dbf
/app/oracle/oradata/testdb/undotbs01.dbf
/app/oracle/oradata/testdb/users01.dbf
/app/oracle/oradata/testdb/example01.dbf
2. control file 확인
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/app/oracle/oradata/testdb/control01.ctl
/app/oracle/oradata/testdb/control02.ctl
/app/oracle/oradata/testdb/control03.ctl
3. online redo log file 확인
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/app/oracle/oradata/testdb/redo01_a.log
/app/oracle/oradata/testdb/redo03_a.log
/app/oracle/oradata/testdb/redo01_b.log
/app/oracle/oradata/testdb/redo03_b.log
4. parameter file / password file 확인
SQL> !ls $ORACLE_HOME/dbs
afiedt.buf hc_testdb.dat lkTESTDB orapwtestdb
hc_DBUA0.dat init.ora log.sql spfiletestdb.ora
5. DB 종료
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
6. 각 백업파일들을 원하는 경로에 복사
[oracle@localhost backup]$ ls -al
#հ# 24
drwxr-xr-x 6 oracle dba 4096 10## 29 20:34 .
drwxr-xr-x 6 oracle dba 4096 10## 29 15:42 ..
drwxr-xr-x 3 oracle dba 4096 10## 29 19:13 close
drwxr-xr-x 2 oracle oinstall 4096 10## 29 20:35 close1
drwxr-xr-x 2 oracle dba 4096 10## 29 19:42 open
drwxr-xr-x 2 oracle oinstall 4096 10## 29 20:34 open1
*cp -av : cp 옵션
a 원본 파일 완전히 똑같은 파일로 복사
v 복사 과정을 직접 보여줌
[oracle@localhost ~]$ cp -av /app/oracle/oradata/testdb/*.dbf /data/backup/close/
`/app/oracle/oradata/testdb/example01.dbf' -> `/data/backup/close/example01.dbf'
`/app/oracle/oradata/testdb/sysaux01.dbf' -> `/data/backup/close/sysaux01.dbf'
`/app/oracle/oradata/testdb/system01.dbf' -> `/data/backup/close/system01.dbf'
`/app/oracle/oradata/testdb/temp01.dbf' -> `/data/backup/close/temp01.dbf'
`/app/oracle/oradata/testdb/undotbs01.dbf' -> `/data/backup/close/undotbs01.dbf'
`/app/oracle/oradata/testdb/users01.dbf' -> `/data/backup/close/users01.dbf'
[oracle@localhost ~]$ cp -av /app/oracle/oradata/testdb/*.ctl /data/backup/close/
`/app/oracle/oradata/testdb/control01.ctl' -> `/data/backup/close/control01.ctl'
`/app/oracle/oradata/testdb/control02.ctl' -> `/data/backup/close/control02.ctl'
`/app/oracle/oradata/testdb/control03.ctl' -> `/data/backup/close/control03.ctl'
[oracle@localhost ~]$ cp -av /app/oracle/oradata/testdb/*.log /data/backup/close/
`/app/oracle/oradata/testdb/redo01_a.log' -> `/data/backup/close/redo01_a.log'
`/app/oracle/oradata/testdb/redo01_b.log' -> `/data/backup/close/redo01_b.log'
`/app/oracle/oradata/testdb/redo02_a.log' -> `/data/backup/close/redo02_a.log'
`/app/oracle/oradata/testdb/redo02_b.log' -> `/data/backup/close/redo02_b.log'
`/app/oracle/oradata/testdb/redo03_a.log' -> `/data/backup/close/redo03_a.log'
`/app/oracle/oradata/testdb/redo03_b.log' -> `/data/backup/close/redo03_b.log'
[oracle@localhost ~]$ cp -av $ORACLE_HOME/dbs /data/backup/close
`/app/oracle/product/11g/dbs' -> `/data/backup/close/dbs'
`/app/oracle/product/11g/dbs/lkTESTDB' -> `/data/backup/close/dbs/lkTESTDB'
`/app/oracle/product/11g/dbs/orapwtestdb' -> `/data/backup/close/dbs/orapwtestdb'
`/app/oracle/product/11g/dbs/log.sql' -> `/data/backup/close/dbs/log.sql'
`/app/oracle/product/11g/dbs/afiedt.buf' -> `/data/backup/close/dbs/afiedt.buf'
`/app/oracle/product/11g/dbs/spfiletestdb.ora' -> `/data/backup/close/dbs/spfiletestdb.ora'
`/app/oracle/product/11g/dbs/hc_DBUA0.dat' -> `/data/backup/close/dbs/hc_DBUA0.dat'
`/app/oracle/product/11g/dbs/hc_testdb.dat' -> `/data/backup/close/dbs/hc_testdb.dat'
`/app/oracle/product/11g/dbs/init.ora' -> `/data/backup/close/dbs/init.ora'
[oracle@localhost ~]$ cd /data/backup/close
[oracle@localhost close]$ ls
control01.ctl example01.dbf redo02_b.log system01.dbf
control02.ctl redo01_a.log redo03_a.log temp01.dbf
control03.ctl redo01_b.log redo03_b.log undotbs01.dbf
dbs redo02_a.log sysaux01.dbf users01.dbf
hot backup
tablespace를 백업 모드로 변경 - OS 명령어로 해당 tablespace의 datafile을 백업장소로 복사 - 파일 복사 후 백업모드 종료
1. 아카이브 로그 모드 확인
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data/arc2
Oldest online log sequence 30
Next log sequence to archive 31
Current log sequence 31
SQL> select tablespace_name, status, contents
2 from dba_tablespaces;
TABLESPACE STATUS CONTENTS
---------- --------- ---------
SYSTEM ONLINE PERMANENT
SYSAUX ONLINE PERMANENT
UNDOTBS1 ONLINE UNDO
TEMP ONLINE TEMPORARY
USERS ONLINE PERMANENT
EXAMPLE ONLINE PERMANENT
6 rows selected.
보기 좋게 화면에 출력하는 명령어들
SQL> set line 200
SQL> col tablspace_name format a10
SQL> col file_name format a50
현재 테이블스페이스 , 데이터 파일을 확인
SQL> select tablespace_name, bytes/1024/1024 MB, file_name
2 from dba_data_files;
TABLESPACE MB FILE_NAME
---------- ---------- --------------------------------------------------
USERS 7.5 /app/oracle/oradata/testdb/users01.dbf
UNDOTBS1 90 /app/oracle/oradata/testdb/undotbs01.dbf
SYSAUX 520 /app/oracle/oradata/testdb/sysaux01.dbf
SYSTEM 710 /app/oracle/oradata/testdb/system01.dbf
EXAMPLE 345.625 /app/oracle/oradata/testdb/example01.dbf
SQL> !
명령어를 따로 치지 않고, 스크립트를 만들어서 핫백업을 받음
스크립트를 만들지않고 각각의 명령어를 따로 입력해도 결과는 같음
스크립트 안에 있는 명령어는 모두 중요
[oracle@localhost backup]$ vi /app/oracle/open_backup.sql
alter tablespace users begin backup;
!cp -av /app/oracle/oradata/testdb/users01.dbf /data/backup/open/
alter tablespace users end backup;
alter tablespace sysaux begin backup;
!cp -av /app/oracle/oradata/testdb/sysaux01.dbf /data/backup/open/
alter tablespace sysaux end backup;
alter tablespace undotbs1 begin backup;
!cp -av /app/oracle/oradata/testdb/undotbs1.dbf /data/backup/open/
alter tablespace undotbs1 end backup;
alter tablespace system begin backup;
!cp -av /app/oracle/oradata/testdb/system01.dbf /data/backup/open/
alter tablespace system end backup;
alter tablespace example begin backup;
!cp -av /app/oracle/oradata/testdb/example01.dbf /data/backup/open/
alter tablespace example end backup;
alter database backup controlfile to '/data/backup/open/control01.ctl'
:wq!
SQL> @/app/oracle/open_backup.sql