닫힌백업
= cold backup = closed backup


※ 현재 상태확인

SQL> select a.group#, a.member, b.bytes/1024/1024 MB, b.archived, b.status
  2  from v$logfile a, v$log b
  3  where a.group# = b.group#
  4  order by 1,2;


 

SQL> select name,status from v$datafile;


 

SQL> select name from v$controlfile;


 

① DB 정상종료

SQL> shutdown immediate;


 
② 전체파일 백업수행
백업경로 : /data/backup/close/

SQL> !
$ cp -av /home/oracle/oradata/testdb/*.dbf /data/backup/close/
$ cp -av /home/oracle/oradata/testdb/*.log /data/backup/close/
$ cp -av /home/oracle/oradata/testdb/*.ctl /data/backup/close/
 
$ cp -av /home/oracle/product/10g/dbs/inittestdb.ora /data/backup/close/
$ cp -av /home/oracle/product/10g/dbs/orapwtestdb /data/backup/close/
$ exit


 
③ DB open

SQL> startup


 
 





열린백업
= hot backup = open backup = begin backup

 : archive redo log mode일때만 쓸수있다.
 


① begin backup상태유무 검사쿼리

SQL> select a.file#, a.name, b.status, to_char(b.time,'YYYY-MM-DD:HH24:MI:SS') as time
  2  from v$datafile a, v$backup b
  3  where a.file# = b.file#;

     FILE# NAME                                               STATUS          TIME
---------- -------------------------------------------------- --------------- --------------------------------------
         1 /home/oracle/oradata/testdb/system01.dbf           NOT ACTIVE      2012-01-31:15:11:38
         2 /home/oracle/oradata/testdb/undotbs01.dbf          NOT ACTIVE      2012-01-31:15:11:36
         3 /home/oracle/oradata/testdb/sysaux01.dbf           NOT ACTIVE      2012-01-31:15:14:25
         4 /home/oracle/oradata/testdb/users01.dbf            NOT ACTIVE      2012-01-31:15:13:51
         5 /home/oracle/oradata/testdb/example01.dbf          NOT ACTIVE      2012-01-31:15:12:13


※ 참고
 STATUS 부분 : ACTIVE면 begin backup 상태,
                       NOT ACTIVE면 end backup 상태이거나 begin backup을 수행하지 않았다는 의미이다.
 TIME 부분 : 가장 마지막에 begin backup 받은 시간


 
② 컨트롤파일 오픈백업

SQL> alter database backup controlfile as '경로/파일이름';


 

③ 스크립트 생성 - 작업 편의성을 위해..
   백업경로 : /data/backup/open/

※ 참고
세 명령어가 한 세트이다.
> begin backup;
! cp
> end backup;


 
 
 

$ vi /home/oracle/open_backup.sql

conn / as sysdba;
 
alter tablespace users begin backup;
! cp -av /home/oracle/oradata/testdb/users01.dbf /data/backup/open/
alter tablespace users end backup;
 
alter tablespace sysaux begin backup;
!cp -av /home/oracle/oradata/testdb/sysaux01.dbf /data/backup/open/
alter tablespace sysaux end backup;
 
alter tablespace undotbs1 begin backup;
!cp -av /home/oracle/oradata/testdb/undotbs01.dbf /data/backup/open/
alter tablespace undotbs1 end backup;
 
alter tablespace system begin backup;
!cp -av /home/oracle/oradata/testdb/system01.dbf /data/backup/open/
alter tablespace system end backup;
 
alter tablespace example begin backup;
!cp -av /home/oracle/oradata/testdb/example01.dbf /data/backup/open/
 
alter tablespace example end backup;
 
alter database backup controlfile to '/data/backup/open/control01.ctl';


 
② 스크립트 실행 

SQL> @/home/oracle/open_backup.sql


 

SQL> alter system checkpoint;


 
Posted by 딩구르
,