반응형

파티션 테이블 유무에 따라 사용법이 나뉩니다.

 

 

1. Non 파티션 테이블 백업

 

- 대상 데이터베이스 : test

- 대상 테이블 : ZIPDB

 

a. FLASH TABLES 권한이 있는 계정으로 접속합니다. (어려우면 root 접속)

   

    MariaDB [TEST]> FLUSH TABLES test.ZIPDB FOR EXPORT;

    Query OK, 0 rows affected (0.013 sec)

 

b. 위의 명령어가 정상적으로 끝나면 기본 데이터 저장하는 곳에 파일 생성됩니다.

   (기본 yum 설치시 : /var/lib/mysql 이며 그 밑에 데이터베이스 명 폴더로 갑니다.)

   cd /var/lib/mysql/test

   ls -lsa를 수행하면 

 

 

  일반적으로 보이지 않는 zipdb.cfg 파일이 하나더 생성됨을 알 수 있습니다.

   ※ 현재 이상태는 백업을 위해 TABLE LOCK을 한 상태입니다.

 

c. 테이블 이동을 위한 복사 작업을 수행합니다

   cp /var/lib/mysql/test/zipdb.ibd /tmp

   cp /var/lib/mysql/test/zipdb.cfg /tmp

 

d. 복사가 정상적으로 끝나면 TABLE LOCK을 풀어줍니다.

  MariaDB [TEST]> UNLOCK TABLES;
  Query OK, 0 rows affected (0.019 sec)

 

위의 작업을 마치면 정상적으로 해당 테이블을 백업 받은 상태입니다.

 

2. Non 파티션 테이블 복구하기

복구할 Database로 2개의 파일(zipdb.ibd, zipdb.cfg)을 복사합니다.

복사시에는 같은 망인 경우 scp를 사용하면 편리합니다.

(scp /tmp/zipdb.* root@대상hostIP:/tmp)

 

a. 먼저 테이블 생성 구문을 동일하게 수행합니다.   

CREATE TABLE `zipdb` (
`ZONE_NO` VARCHAR(5) NOT NULL COMMENT '구역번호(우편번호)',
`CTPRVN` VARCHAR(20) NULL DEFAULT NULL COMMENT '시도',
`CTPRVN_ENG` VARCHAR(40) NULL DEFAULT NULL COMMENT '시도영문',
`SIGNGU` VARCHAR(20) NULL DEFAULT NULL COMMENT '시군구',
`SIGNGU_ENG` VARCHAR(40) NULL DEFAULT NULL COMMENT '시군구영문',
`EUP_MYEON` VARCHAR(20) NULL DEFAULT NULL COMMENT '읍면',
`EUP_MYEON_ENG` VARCHAR(40) NULL DEFAULT NULL COMMENT '읍면영문',
`RN_CODE` VARCHAR(12) NULL DEFAULT NULL COMMENT '도로명코드',
`RN` VARCHAR(80) NULL DEFAULT NULL COMMENT '도로명',
`RN_ENG` VARCHAR(80) NULL DEFAULT NULL COMMENT '도로명영문',
`UNDGRND_AT` VARCHAR(1) NULL DEFAULT NULL COMMENT '지하여부(0:지상, 1:지하)',
`BDNBR_MNNM` INT(5) NULL DEFAULT NULL COMMENT '건물번호본번',
`BDNBR_DUCA` INT(5) NULL DEFAULT NULL COMMENT '건물번호부번',
`BULD_MANAGE_NO` VARCHAR(25) NULL DEFAULT NULL COMMENT '건물관리번호',
`MUCH_DLVR_OFFIC_NM` VARCHAR(40) NULL DEFAULT NULL COMMENT '다량배달처명(null)',
`SIGNGU_BDNBR_NM` VARCHAR(200) NULL DEFAULT NULL COMMENT '시군구용건물명',
`LEGALDONG_CODE` VARCHAR(10) NULL DEFAULT NULL COMMENT '법정동코드',
`LEGALDONG_NM` VARCHAR(20) NULL DEFAULT NULL COMMENT '법정동명',
`LI_NM` VARCHAR(20) NULL DEFAULT NULL COMMENT '리명',
`ADSTRD_NM` VARCHAR(40) NULL DEFAULT NULL COMMENT '행정동명',
`MNTN_AT` VARCHAR(1) NULL DEFAULT NULL COMMENT '산여부(0:토지, 1:산)',
`LNM_MNNM` INT(4) NULL DEFAULT NULL COMMENT '지번본번',
`EMD_SN` VARCHAR(2) NULL DEFAULT NULL COMMENT '읍면동일련번호',
`LNM_DUCA` INT(4) NULL DEFAULT NULL COMMENT '지번부번',
`OLD_ZIP` VARCHAR(6) NULL DEFAULT NULL COMMENT '구 우편번호(null)',
`ZIP_SN` VARCHAR(3) NULL DEFAULT NULL COMMENT '우편번호일련번호(null)', INDEX `ZIPDB_IX1` (`ZONE_NO`), INDEX `ZIPDB_IX2` (`CTPRVN`, `SIGNGU`, `EUP_MYEON`), INDEX `ZIPDB_IX3` (`RN_CODE`), INDEX `ZIPDB_IX4` (`RN`)
) COLLATE='utf8_general_ci' ENGINE=InnoDB
;

b. 생성후에는 ALTER TABLE ... DISCARD TABLESPACE 명령을 사용하여 새로운 테이블의 테이블스페이스를 폐기합니다.

MariaDB [TEST]> ALTER TABLE test.zipdb DISCARD TABLESPACE;

c. ibd 파일과 cfg 파일을 데이터베이스 (test) 폴더에 붙여 넣습니다.

복구할 서버 데이터베이스 저장 위치 : /var/lib/mysql/test

 

# cp /tmp/zipdb.* /var/lib/mysql/test/

 

root 권한으로 복사시에는 아래의 퍼미션을 부여합니다.

# chown -R mysql:mysql /var/lib/mysql/test/zipdb.*

 

.ibd 파일 만으로도 테이블 스페이스로 파일을 가지고 올 수 있습니다.   

(.cfg 파일은 테이블 스페이스 정보 가지고 있음)

 

d. 다음 명령을 사용하여 새 테이블에 데이터를 가지고 옵니다.

 

MariaDB [(none)]> ALTER TABLE test.zipdb IMPORT TABLESPACE;

퍼미션이 맞지 않는 경우 다음의 에러가 발생

ERROR 1030 (HY000): Got error 194 "Tablespace is missing for a table" from storage engine InnoDB

 

 

e. 복구 결과

   정상적으로 모든 데이터 건수가 일치하는 것을 알 수 있습니다.

 

파티셔닝 복구 방식

https://mariadb.com/kb/en/library/innodb-file-per-table-tablespaces/

 

InnoDB File-Per-Table Tablespaces

InnoDB file-per-table tablespaces: what they are, where they're located, how to copy them, and other details.

mariadb.com

 

반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB connect 설치  (0) 2019.11.07
MariaDB JSON 컬럼 및 함수들  (0) 2019.11.04
MariaDB 우편번호 Import 하기  (0) 2019.11.01
MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
반응형

* 컨테이너 커밋은 기 Container 파일내에 변경 사항에 대한 내용을 image 화 하는 방식임.


1.  Docker 컨터이너 커밋
   - docker에서 작업한 컨테이너를 그대로 저장합니다.
     (별도로 기본 이미지에서 변경한 내역이 있을 때 사용)
   
   - docker commit [CONTAINER] [백업할 IMAGE_NAME]
   - 예)
   [root@localhost ~]# docker ps
CONTAINER ID        IMAGE                                                COMMAND                  CREATED             STATUS              PORTS                                                                           NAMES
2df5d23dbe0e        docker.test.io:8081/solution-was/2.1/x64:latest         "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        0.0.0.0:8888->8080/tcp                                                          docker_was_1
509d8e8f79c6        docker.test.io:8081/solution-dtg/2.1/x64:latest         "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        1337/tcp                                                                        docker_dtg_1
22bc42e1e8f7        docker.test.io:8081/solution-mhp/2.0/x64:latest         "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        1335/tcp, 1337/tcp, 1339-1341/tcp, 3882/tcp, 0.0.0.0:9900-9999->9900-9999/tcp   docker_mhp_1
dfce80fcd38f        docker.test.io:8081/solution-geoserver/2.2/x64:latest   "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        8080/tcp                                                                        docker_geoserver_1
eb18ba2b9010        postgres:10.5                                        "docker-entrypoint..."   4 months ago        Up 5 minutes        5432/tcp                                                                        docker_postgresdb_1
2c8ec75d22ed        cassandra:3.11.3                                     "docker-entrypoint..."   4 months ago        Up 5 minutes        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp                                     docker_cassandra_1
a427d7f36829        mongo:3.4                                            "docker-entrypoint..."   4 months ago        Up 5 minutes        0.0.0.0:27017->27017/tcp                                                        docker_mongodb_1

   위의 내용에서 docker_was_1 컨테이너를 commit할 예정
   
   [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              a85e7acc572a        6 months ago        1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB

  [root@localhost ~]# docker commit docker_was_1 docker.test.io:8081/solution-was/2.1/x64:latest
sha256:b4fd018ea938c46eae246ca8f6daa586c7216919b4be21a0e980bf05fca82dc0
[root@localhost ~]#

  위의 보이는 것처럼 b4fd018ea938c46eae246ca8f6daa586c7216919b4be21a0e980bf05fca82dc0 이름으로 이미지가 생성됩니다.
  
  [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        10 seconds ago      1.23 GB
docker.test.io:8081/solution-was/2.1/x64                       a85e7acc572a        6 months ago        1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB


  - 만든 이미지의 임의의 이름 부여
  [root@localhost ~]# docker tag docker.test.io:8081/solution-was/2.1/x64 mydocker_last

  - 내역 조회
  [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED              SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        About a minute ago   1.23 GB
mydocker_last                                 latest              b4fd018ea938        About a minute ago   1.23 GB
docker.test.io:8081/solution-was/2.1/x64                       a85e7acc572a        6 months ago         1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago         1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago         519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago         1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago         323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago         361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago         1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago         1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago         228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago        1.15 GB

     
 
2. docker 이미지 백업 및 배포

위에서 만든 mydocker_last 이미지를 백업 받습니다.

[root@localhost ~]# docker save -o mydocker_last_20190626.tar mydocker_last

[root@localhost ~]# ls -lsa mydocker*.tar
1229636 -rw------- 1 root root 1259146752 Jun 26 04:06 mydocker_last_20190626.tar


위의 생성된 내역을 기준으로

* 사전에 docker-compose로 전체를 내리고 수행 필요

a. docker rm [컨테이너 삭제]
b. docker rmi [이미지 삭제]

이미지 로드

[root@localhost ~]# docker load -i mydocker_last_20190626.tar
9186e1e3577e: Loading layer [==================================================>] 4.608 kB/4.608 kB
5e98fb5934af: Loading layer [==================================================>] 157.5 MB/157.5 MB
f33686d99dec: Loading layer [==================================================>] 2.048 kB/2.048 kB
f30a15d54bfb: Loading layer [==================================================>] 2.048 kB/2.048 kB
825ca8132690: Loading layer [==================================================>]  29.7 kB/29.7 kB
Loaded image: mydocker_last:latest
[root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
mydocker_last                                 latest              b4fd018ea938        12 minutes ago      1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB


기존 명칭으로 mydocker_last를 변경

 # docker tag mydocker_last docker.test.io:8081/solution-was/2.1/x64 
 
 [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        13 minutes ago      1.23 GB
mydocker_last                                 latest              b4fd018ea938        13 minutes ago      1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB

복제된 기존 태그 삭제
[root@localhost ~]# docker rmi mydocker_last
Untagged: mydocker_last:latest
[root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        14 minutes ago      1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB

반응형
반응형

1. svn 백업

아래는 다음과 같은 값을 가질 때 예

svn root : /var/svn

저장소명 : gov

백업 파일명 : gov_backup.dump

#> svnadmin dump /var/svn/gov > gov_backup.dump

 

2. svn 복구

svn root 위치에 해당 파일(gov_backup.dump)

복사후 수행

 

a. 저장소 생성

#> svnadmin create --fs-type fsfs gov

 

b. 생성된 저장소에 내용 로드

#> svnadmin load gov < gov_backup.dump

반응형

'Private' 카테고리의 다른 글

웹 페이지 성능분석 및 로딩 속도 최적화  (0) 2019.09.03
D3  (0) 2019.05.31
node-red oracledb  (0) 2018.06.25
서버 용량 산정 / 성능 측정 / tpmc / bops / tpc / tpc-h  (0) 2013.05.10
오라클 접속 ORA-12505 에러 관련  (0) 2013.05.02
반응형


FTK Imager 이슈


스마트폰 속 개인정보, 삭제해도 쉽게 복원된다 : http://economy.hankooki.com/lpage/it/201407/e20140710145634117700.htm

AccessData의 Forensic 이미징 도구 : FTK Imager 3.0 : http://solatech.tistory.com/208


위 블로그에 자세한 사항을 찾고하면 되겠다 ^^(포렌식 관련)


난 그중 위의 파일 복구 관련하여 한번 살펴보았다... 속도도 빠르고 검색 능력도 뛰어남....


다운로드 : http://www.accessdata.com/support/product-downloads

https://accessdata.com/product-download

2019.03.27 기준 : 4.2.1 버전이 최신 버전이며 이메일로 다운로드 주소가 보내집니다.



3.1.1 버전을 다운로드 받아 실행함 (일반적인 설치과정이라 별 다를게 없음...)


파일 복구 간단한 사용법...


설치 -> FTK Imager 실행 


1. 특정 드라이브 연결

   - File -> Add Evidence Item... 선택 -> Physical Driver (이동식 USB 연결) -> 60 여 기가의 usb 연결 선택 -> 마침






2. 이동식 USB 연결된 파일의 목록이 좌측에 뜨고

    지워진 (X 표시가 뜬) 파일이나 폴더를 선택하여 마우스 우클릭시 Export Files... 선택하여 복원하면 끝






















 









반응형
반응형

후암..


우선,


참고 : http://www.mondorescue.org(확인해봐야하는 백업 복구 사이트!)

참고 : http://readytoact.tistory.com/159 (G4l) => Ghost for Linux  여기로 해본다...


clonezilla 를 하라는 말 부터 하고 ... http://clonezilla.org


아래는 생짜배기(압축과 풀기)로 하는 방식...


출처 : http://kldp.org/node/84594


이글은 우분투 포럼에 A-star라는 작자가 올린 글을 요약 정리 한겁니다.
http://ubuntuforums.org/showthread.php?t=81311

방법은 간단합니다.
tar로 전체 시스템을 압축하는 명령어를 사용하면서 
/proc , /lost+found , /mnt , /sys 는 제외하고 압축하고 
나중에 복원은 이 파일 압축 푸는 방식입니다.

===========압축=========================

방법은 아래에 순서대로 작성했습니다.

sudo su 
cd /
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/media --exclude=/sys /

그러니까 루트 권한으로 바꾸고 나서 최상위 리스트로 올라가서 tar 명령어를 적용하는데 
압축 파일이름은 backup.tgz로 하고 압축시 /proc , /lost+found , /mnt , /sys, /media 는 제외하자는 겁니다.
각자 사정에 맞춰서 제외할 디렉토리는 더 추가하시면 되겠죠.

그런 후에 backup.tgz파일을 dvd로 굽든 랜으로 다른 컴터로 옮기시든 하시면 되겠죠.

압축 종료후 나오는 'tar: Error exit delayed from previous errors'란 메세지는 쌩까시면 됩니다.
압축률을 좀더 높이자면 Bzip2나 7zip으로 압축하시면 됩니다.
Bzip2로 압축할 경우 아래 명령어를 쓰시면 됩니다. (cvpzf에서 cvpjf로 옵션을 바꿔야합니다.)

tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/media --exclude=/sys --exclude=/boot /

==============복원===================
backup.tgz는 루트디렉토리에 있어야합니다. 
sudo su
그리고 아래 명령어를 먹여주면 됩니다.
tar xvpzf backup.tgz -C /

Bz2로 압축한 경우 
tar xvpjf backup.tar.bz2 -C /

그러고 나서 압축시 제외했던 폴더는 따로 만들어 주면됩니다mkdir sys.
아래처럼 
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
mkdir media
etc...
=====================================

만약 압축하고 자시고 하는게 너무 귀찮다하시면 아래 방법을 쓰면 됩니다.
이건 어떤 분 블러그에서 보고 배운건데 
원본 시스템이 깔린 하드 A가 있고 그 시스템을 똑같이 복사할 하드 B가 있다고 하면 
하드 B를 하드 A에 케이블로 연결을 해서 아래 명령어를 적용시키면 됩니다.

cat (하드A) > (하드B)

만약 하드 A 위치가 /dev/hdb이고 하드 B 위치가 /dev/hdc라면 이렇게 되는거죠.

cat /dev/hdb > /dev/hdc

그러면 하드A의 내용이 하드B에 완전히 모조리 똑같이 백업됩니다. 당연히 시스템 디바이스 관련된것도
같이 가니까 사용할 컴터 스펙은 동일해야겠죠.

반응형

'OS > Linux' 카테고리의 다른 글

vi 색상 표기  (0) 2019.05.08
CENTOS 7에 XRDP 설치하기  (0) 2017.08.26
삼성 컴퓨터 유분투 설치기.  (0) 2012.02.06
rkhunter (리눅스 침입 탐지 사용하기)  (1) 2010.10.14
ps auxc 와 ps aux 결과 비교하기  (0) 2010.01.21
반응형


CD 롬 정보 얻어오는 스크립트(dvd.bat)


 @echo off

set USB_DRIVE=none

for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (

   for %%c in (%%b) do (

      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (


         if %%d equ CD-ROM (

            set DVD=%%c:

          )

          

      )

   )

)





자동으로 복구하는 BATCH 스크립트 (setup.bat)


 @echo off

setlocal


rem call 은 같은 화면 / start은 별도로 수행

call dvd.exe


::::::::::::::::::::::::::::::::::::::::::::::

:LOOP

color 1F

cls

echo.

echo.

echo.

echo.                  ◀ 고스트 자동 복구용 ▶

echo. 

echo.            1. Centos 6.3 복구 (DVD -^> resource\backup.gho)

echo.                (ID : root / password : 1q2w3e )

echo. 

echo.            2. Partition Wizard Professional Edition

echo.

echo.            3. Q-Dir

echo.

echo.            4. reboot

echo.

echo.            ※ 리눅스 복원(1번)은 모든 데이터가 지원지니

echo.

echo                제안서 작업 폴더 등은 백업 후 수행 하세요

echo.

echo                자세한 사항은 root로 로그인 한 뒤 바탕화면 참고하세요

echo.

echo.

set /p ANS="☞ 번호를 입력해 주세요 : "


if "%ANS%" == "1" goto MENU1

if "%ANS%" == "2" goto MENU2

if "%ANS%" == "3" goto MENU3

if "%ANS%" == "4" goto QUIT


goto LOOP

:::::::::::::::::::::::::::::::::::::::::::::::

:MENU1

echo.

echo. Windows 7 Restore

echo. 

start x:\ghost32 -clone,mode=load,src=%DVD%\sources\backup.gho,dst=1 -sure -fx

goto LOOP


:MENU2

echo.

echo "Partition Wizard Run~"

start x:\PartitionWizardPro6.exe

echo.

goto LOOP


:MENU3

echo.

echo "Q-Dir Run"

echo.

start x:\Q-Dir.exe

goto LOOP


:QUIT

reboot






반응형
반응형

홈페이지 : http://www.todo-backup.com/business/free-backup/features.htm 
기능 : 백업 및 복구 (고스트 대체 기능)
장점 : Backup Free 버젼은 freeware 버젼이라는것...

일부 외국 사이트에서는 ghost(고스트) 대체 가능한 프로그램이라고 설명하고 있습니다....
(http://www.raymond.cc/blog/archives/2009/10/31/easeus-todo-backup-free-disk-imaging-software-norton-ghost-alternative/)
 
지원기능들(의역하였습니다...하앍...)

1. 백업
   - 백업시스템 : 윈도우가 동작중일때라도 충돌없이 전체 시스템과 설치된 응용 프로그램까지 백업가능. 
   - 모든파일백업 : 네트워크 공유파일, 정의된 파일 목록등 선택적이나 전체를 풀로 백업 가능.
   - 스케줄 백업 : 시간/일/주/월 단위로 백업 계획을 작성할 수 있고 PC에 대한 백업을 설정하고 잊더라도 정기적 백업이 가능함.
   - 증가 디스크 및 파일 백업 : 마지막 백업된 디스크와 피티션 정보의 변경분 백업으로 저장공간을 절약할 수 있다.
   - 이벤트 기반 백업 : 시스템 시작 / 종료 /가 로그아웃의 사용자 로그온과 같은 이벤트 또는 조건에 따라 백업을 만들 수 있습니다.
    - 이메일 통지 : 성공 또는 실패 모니터링에 대한 이메일 통지
    
...


 너무 길어서... 번역기 돌림..

=========================================================================================================
 지원

백업 시스템 - 다시 전체 시스템 상태를 백업, 윈도우 작업을 방해하지 않고 운영 체제와 - the - fly 방식에 설치된 응용 프로그램을 포함한
모든 파일을 백업 - 네트워크 공유 파일, 지정된 파일 및 폴더와 파일 형식의 종류가 꽉 찼거나 선택 백업할 수 있습니다.
백업 일정 - 시간 / 일 / 주 / 월하여 백업을위한 계획을 작성하고 PC에 "그것을 설정하고 그것을 잊지"백업 정기적으로 백업을 자동화합니다.
증분 디스크 및 파일 백업 - 마지막으로 디스크 / 파티션 또는 파일 백업 이후 파일의 변경 사항을 백업하고 저장 공간을 저장합니다.
이벤트 기반 백업 - 시스템 시작 / 종료 /가 로그아웃의 사용자 로그온과 같은 이벤트 또는 조건에 따라 백업을 만들 수 있습니다.
이메일 통지 - 이메일 통지하고 성공 또는 실패를 모니터링보고.
유연한 백업 스토리지 - 더블 보호를위한 백업 시스템 또는 로컬 하드 드라이브에 데이터를 외장 하드 드라이브, USB 드라이브 또는 CD / DVD가 재해가 발생하는 경우.
디스크 및 파티션 백업 - 전체 하드 디스크 또는 시스템 보호 또는 마이 그 레이션에 대한 파티션을 백업.
회복

선택적 파일이 복원 - 선택 전체 이미지를 복구하지 않고 파일 및 백업 이미지에서 폴더를 복구
유니버설 복원 - WinPE 부팅 디스크를 만든 다음 쉽게 하드웨어 교체를위한 ...와 비슷하지 않은 하드웨어 구성으로 시스템을 복원하거나 마이 그 레이션하는 몇 가지 단계를.
디스크 및 파티션 복구 - 빠른 전체 하드 디스크 또는 하드 디스크를 업그레 이드 및 마이 그 레이션하는 원본 또는 다른 하드웨어 파티션을 복구합니다.
백업 이미지 파일을 탐색 세밀한 수준으로 복원 - 탐색 복사 및 Windows 탐색기에서 백업 이미지에서 직접 파일과 폴더를 복원합니다.
종합 백업 관리

디스크 공간을 절약하기 위해 오래된 이미지를 삭제 - 시간 설정에 따라 자신의 디스크 공간을 절약하기 위해 자동으로 덮어 씁니다 / 삭제 된 이미지.
압축 - 저장 공간을 최적화하기 위해 압축 백업.
분할 백업 - 미디어에 맞게 분할 백업 이미지 파일 크기로.
편집,보기 백업 작업 / 계획 삭제 중앙 관리 콘솔에 있습니다.
백업 업데이트 - 적시 보호를위한 백업 변경 사항을 업데이 트하십시오.
백업 지속적인 지표 일정 - 일정이 진행 여부를 적시에 통지를하고, 허용 수동으로 일정을 취소합니다.
이중 보호를위한 서버를 FTP로 백업 - 원격 FTP 서버로 PC와 파일을 백업 및 이중 즉각적인 오프 사이트 백업을 사용하여 PC를 보호합니다.
P2V 이미지 파일 지원을 변환 - 가상 머신에서 실행하는 VM웨어 또는 가상 PC를 포맷으로 하드 디스크 또는 파티션 이미지 파일을 변환합니다.
사전 / 사후 명령 - 이후 또는 백업 작업을하기 전에 명령을 실행 명령을 (스크립트) 정의합니다.
보고 로그 - 기록과 PC에 대한 모든 작업을 볼 수 있습니다.
고급 백업 및 디스크 도구

디스크 클론 - 하드 디스크의 정확한 이미지 복사본을 생성하고 정확하게 다른 모든 파일을 마이 그 레이션.
파티션 클론 - 파티션의 정확한 이미지 복사본을 생성하고 정확하게 다른 모든 파일을 전송합니다.
이미지를 확인 - 이미지 파일의 무결성을 확인하고 백업이 성공적으로 복원할 수 있는지 확인하십시오.
마운트 / 마운트 해제 이미지 - 그것에있는 파일을 탐색하거나 복사하는 가상 파티션 (일반, 논리 드라이브로 작업)에 디스크와 파티션 이미지를 마운트.
보안

백업 이미지에 대한 비밀 번호 보호 - 무단 액세스로부터 백업 이미지를 보호할 수 있습니다.
데이터를 닦아 - 모든 민감하거나 기밀 파일을 영구적으로 필요한 경우를 닦으십시오.
다중 작업 환경

지원 Windows 2000/XP/Vista/7



=========================================================================================================

복구시 아래 링크와 같은 방법으로 부팅 디스크를 만들수 있다

http://www.todo-backup.com/products/features/winpe-bootable-disk.htm
 
반응형

'UTILITY' 카테고리의 다른 글

ERD 관련 프로그램 들...  (0) 2011.08.19
registry first aid platinum v 8.1  (1) 2011.08.08
외장 장치 쓰기 금지 미디어 일때 사용방법  (0) 2011.07.23
Acroedit 소개  (0) 2011.06.28
NetDrive 설정해 보기  (0) 2011.06.28
반응형


I. RECOVERY ON A TEST MACHINE:
이 부분이 다른 서버에서 복구하는 것이구요.

II. RECOVERY ON A PRODUCTION MACHINE:
이 부분이 동일 서버에서 인스턴스 하나 띄워서 복구하는 것입니다.
문서 보시고 하면 됩니다.



PURPOSE
-------

This bulletin outlines the steps to perform recovery to restore
a dropped table without recovering the entire database.  The bulletin
assumes the reader is familiar with Oracle's recovery procedures which
are documented in the Oracle documentation set.

SCOPE & APPLICATION
----------------------

This bulletin discusses dropped table recovery using traditional (Oracle7)
backup and recovery procedures. These can equally be applied to Oracle8. It
does NOT discuss tablespace point in time recovery (TSPITR) or the Recovery
Manager (RMAN) duplicate database feature.

The examples in this bulletin are UNIX-based, but can be easily applied to
other platforms with little modification.


RECOVERING A DROPPED TABLE FROM A FULL DATABASE BACKUP
------------------------------------------------------

TERMINOLOGY
-----------

PROD machine - Host computer on which the production database runs. Also
               denotes the ORACLE_SID of the production instance.
TEST machine - Host computer, physically distinct from the machine on which the
               production database runs.
TEMP         - The ORACLE_SID of the instance used to access the restored
               database.
The backup   - The set of backed up database structures (see REQUIREMENTS) used
               as the basis for recovering the dropped table. Once restored,
               this set of structures is referred to as the partially restored
               database.

REQUIREMENTS
------------

The following data structures must be available from the backup:
- All system tablespace datafiles
- All rollback segment datafiles
- All datafiles in which the table to recovered is stored
- Archive logs - see Note (a)
Notes:
 (a) If the restored datafiles are part of a hot backup, or you wish to
     roll them forward, the required archivelogs must be available.

In an ideal world the partially restored database will be made available for
recovery on a TEST machine. However this may not always be possible, and
it may be necessary to restore to the same machine on which the 'source'
(PROD) database resides. The latter is NOT RECOMMENDED as a user error in the
recovery process can corrupt the production database.

If the datafiles comprising the partially restored database were in hot
backup mode at the time the table was dropped, it is necessary to restore
a previous backup. The reason for this is that the hot backup must be rolled
forward past the 'end backup' markers (the time that the tablespaces were taken
out of hot backup mode) before the database can be opened. Failure to recover
the restored datafiles past their end backup markers will result in the
following error when an attempt is made to open the database:

  ORA-1195 "online backup of file %s needs more recovery to be consistent"

I. RECOVERY ON A TEST MACHINE:
------------------------------

The following steps are to be used when performing recovery on a TEST machine,
the assumption being that there is no instance with the ORACLE_SID "PROD"
or "TEMP" already running on the TEST machine.

 1. On the PROD database, connect as a privileged user and create an ASCII
    dump of the controlfile. For example:

      SVRMGR> connect / as sysdba
      SVRMGR> alter database backup controlfile to trace resetlogs;

    A trace file will be generated in the user_dump_dest destination. Rename
    this trace file to ccf.sql and save it.

 2. Create a directory on the TEST machine. The restored database will be
    located in this directory. In this example the directory is called
    /RESTORE. The only stipulation is that there is enough space to easily
    accomodate the restored database and any archivelogs required for recovery.
    If filesystem space is at a premium, the archivelogs may be optionally
    restored to /RESTORE as required by recovery, and removed after they have
    been applied.

 3. Restore the backup to the /RESTORE directory.

 4. Optionally, restore all archivelogs required for recovery to the /RESTORE
    directory.

 5. Copy the init.ora file (initPROD.ora) from the PROD database to the /RESTORE
    directory on the TEST machine. This assumes that all database parameters are
    specified in only the init.ora file. If an include files (ifile) is
    referenced, also copy this file to /RESTORE.

 6. Rename the initPROD.ora to initTEMP.ora on the TEST machine.

 7. Edit the initTEMP.ora and make the following modifications:
    a. control_files = /RESTORE/cntrlTEMP.dbf
    b. if applicable, change any ifile references to point to the copied
       include file
    c. log_archive% parameters should be changed to reflect the restored
       archivelogs:
         log_archive_destination
         log_archive_format
       For example:
         log_archive_destination=/RESTORE
         log_archive_format=arch_%s.dbf
    d. %dump_dest parameters should be changed to point to suitable directories

    e. If audit is on, turn it off.

 8. Ensure that the shell environment is set correctly. At the very least, the
    following environment variables must be defined:
    a. ORACLE_HOME
    b. ORACLE_SID (should be set to TEMP)

 9. Connect as a privileged user. For example:

      SVRMGR> connect / as sysdba

10. Start the instance, specifying TEMP's init.ora:

     SVRMGR> startup nomount pfile=/RESTORE/initTEMP.ora

11. The ccf.sql file (created in Step 1) contains the syntax necessary to
    create a new controlfile. Copy this script to the TEST machine and edit
    it to save only the text between (and including) 'CREATE CONTROLFILE'
    and it's terminating semi-colon. Modify the following sections:

    a. LOGFILE. Edit this section to reflect the names of the online logs to
       be created for the TEMP instance. If the PROD instance has a large
       number of large online log members, it is advisable to specify a
       reduced number of smaller log members. You MUST however specify at
       least two online log groups.
    b. DATAFILE. Edit this section to reflect the names of the restored
       datafiles only.
    c. Miscellaneous:
       - Remove the REUSE keyword
       - Optionally change the ARCHIVELOG keyword to NOARCHIVELOG (so the
         TEMP database will not operate in archivelog mode)

    An example of the completed ccf.sql script might be:

      CREATE CONTROLFILE DATABASE "PROD" RESETLOGS NOARCHIVELOG
          MAXLOGFILES 16
          MAXLOGMEMBERS 2
          MAXDATAFILES 20
          MAXINSTANCES 1
          MAXLOGHISTORY 337
      LOGFILE
        GROUP 1 '/RESTORE/log1PROD.dbf'  SIZE 1M,
        GROUP 2 '/RESTORE/log2PROD.dbf'  SIZE 1M
      DATAFILE
        '/RESTORE/sys1PROD.dbf',
        '/RESTORE/rbs1RBS.dbf',
        '/RESTORE/users1PROD.dbf'
      ;

    Then execute ccf.sql script to create control file(s).

12. Recover the database. The database is to be recovered to a time before
    the table was dropped. There are two options here:
    a. Time-based incomplete recovery. Database recovery is stopped at the
       specified date and time.
    b. Cancel-based incomplete recovery. Database recovery is stopped on
       an archivelog boundary i.e. the granularity of cance-based recovery
       is the archivelog.

    Example of time-based recovery:

      SVRMGR> recover database until time '2000-01-10:12:00:00' using backup controlfile

    In the above example, apply archivelogs as requested. Recovery will stop
    automatically at 12:00 on Januaru 10th, 2000.

    Example of cancel-based recovery:

      SVRMGR> recover database until cancel using backup controlfile

    As soon as you have applied the last desired archivelog, type CANCEL
    to stop recovery.

13. Open the database with the RESETLOGS option:

      SVRMGR> alter database open resetlogs;

14. Export the table(s).

15. Import the table(s) into the PROD database.

16. Once the necessary tables have been imported, the TEMP instance can be
    shutdown and all associated files removed. It is worthwhile verifying that
    the import has completed successfully before removing the TEMP instance.

II. RECOVERY ON A PRODUCTION MACHINE:
-------------------------------------

If a TEST machine is not available for performing recovery, the PROD machine
can be used. It is important to exercise extreme caution when doing this. The
restored database will be operate under the TEST instance as before. During
this procedure the restored database's name is changed in order to avoid
problems in acquisition of the mount lock.

 1. Take a FULL backup of the database running against the PROD instance
    before performing any recovery.

 2. While connected to the PROD instance, create an ASCII dump of the
    controlfile:

      SVRMGR> connect / as sysdba
      SVRMGR> alter database backup controlfile to trace resetlogs;

 3. Create a /RESTORE directory as before (Step 2 above).

 4. Restore the backup (and optionally the archivelogs) to the /RESTORE
    directory (Steps 3 and 4 above).

 5. Create the initTEMP.ora file (Steps 5, 6, 7 above). In addition to the
    changes already made, modify the db_name parameter, for example:
      db_name=TEMP

 6. Ensure that the shell environment is set correctly (Step 8 above):
    a. ORACLE_HOME
    b. ORACLE_SID (should be set to TEMP)

 7. Start the TEMP instance (Steps 9, 10 above). It is critical to ensure
    that the correct pfile is used to start the instance.

 8. Modify the ccf.sql file (Step 11 above). It is critical to ensure that
    the DATAFILE and LOGFILE names reference the backup location and NOT the
    PROD instance database's files. In addition to the changes already made,
    modify the first line to set the new database name, for example:
      from: CREATE CONTROLFILE DATABASE "PROD" RESETLOGS NOARCHIVELOG
        to: CREATE CONTROLFILE SET DATABASE "TEMP" RESETLOGS NOARCHIVELOG

 9. Recover the database (Step 12 above).

10. Open the database (Step 13 above).

11. Export the table(s).

12. Import the tables(s).

13. Cleanup the TEMP instance (Step 16 above).

반응형

'Database > ORACLE' 카테고리의 다른 글

tnsnames.ora 등록 없이 Database Link 만들기  (0) 2010.08.03
System Account Lock (System 계정 락 걸림)  (0) 2010.07.15
PL/SQL Exception  (0) 2010.07.06
RMAN 사용법  (0) 2010.07.06
오라클 암호화 기능  (0) 2010.07.02
반응형

################################################################
1. Backup 하기

################################################################



1.
백업 가능대상
 

 - database (all datafile 과 현재 control file)
 - tablespace
 - datafile (current 또는 image copy)
 - archived redo log
 - control file (current 또는 image copy)
   
* 백업이 되는 않는 대상( init.ora, password file. listener.ora, tnsnames.ora, BFILES)

 

2. 백업 분류 

 - consistent vs Inconsistent 백업

     RMAN을 통한 백업은 대상 DB open 혹은 close된 시점에서 백업이 가능하며, open 상태에서의 백업은 항상 Inconsistent 이며, consistent 백업은 항상 mount상태에서 백업을 받은 것을 말하며 이전에 DB crash되거나 비 정상 종료가 되지 않아야 한다.

     ( NOARCHIVE MODE에서는 INCONSISTENT 백업을 허용하지 않는다)  


3.
백업 방법
3.1 전체 database 백업 

 run {

        allocate channel c1 device type disk;

        backup database

        format ‘/data/backup/rman/%d_%p_%t’;

  }

 
3.2 tablespace 백업

 run {

       allocate channel c1 device type disk;

       allocate channel c2 device type disk;

       allocate channel c3 device type disk;

       backup filesperset=3                                  ## 한 백업set datafile 3개를 넘어서 백업받지 않는 조건

       tablespace example , users,system

       include current controlfile;                          ## 현재 control file도 같이 백업

 }


3.3 datafile
백업

 run {

       allocate channel c1 device type disk;

       backup  datafile 1, 2, 3, 4, 5, 6 ;

 }

 
3.4 datafile copy

 run {

        allocate channel c1 device type disk;   

        backup datafilecopy ‘/home/oracle/oradata/testdb/users01.dbf’

        format ‘/data/backup/rman/users01.bak’;

 }

 
3.5 current control file 백업

 run {

       allocate channel ch1 type disk;

       backup current controlfile

       tag = mondayPMbackup;

  }

 
3.6 다른 object 백업시 control file 백업 추가 방법

 run {

       allocate channel ch1 type disk;

       backup tablespace users

       include current controlfile;                          ## users 라는 tablespace 백업시 currnet control file 포함

 }

 
3.7 Archive redo log 백업

 

 run {

       allocate channel ch1 type disk;

       backup archivelog all                                 ## archive된 모든 redo log 백업

       delete input;                                               ## 백업받은 archive log 삭제

 }

 

 * archived redo log 백업시 time, SCN, log sequence number 조건을 사용해서 백업 받을수 있다.

    예) time 조건

 run {

        allocate channel ch1 type disk;

        backup archivelog

        from time ‘SYSDATE-2’ until time ‘SYSDATE-1’;         ## 2일전부터 1일전까지 발생한 archived redolog

 }                                                                                              

 

4. incremental 백업

 

 run {

       allocate channel ch1 type disk;

       backup incremental level=0                        ## level 0 으로 database incremental backup

       database;

 }

 

 run {

       allocate channel ch1 type disk;

       backup incremental level=1                        ## level 1 system tablespace sale.f datafile 을 백업

       tablespace system                                     ##   하는데 level 0 또는 1이후로 변경된 사항만

       datafile ‘/home/oracle/oradata/testdb/example01.dbf’;   ##                     백업받는다.

 }

 

 run {

       allocate channel ch1 type disk;

       backup incremental level=2 cumulative       ## level 2 tbs_1 tablespace 백업하는데 level 0 또는 1

       tablespace  example;                                 ## 이후로 변경된 사항만 백업(cumulative 옵션사용)

 }

 

 

5. image copies

 

1. datafile

2. archived redo log

3. control file

 
5.1 datafile controlfile image copy

1)

 run {

       allocate channel ch1 type disk;

       copy

       datafile 1 to ‘/data/backup/rman/df_1.bak,

       datafile 2 to ‘/data/backup/rman/df_2.bak’,

       datafile 3 to ‘/data/backup/rman/df_3.bak’,

       datafile 4 to ‘/data/backup/rman/df_4.bak’,

       current controlfile to ‘/data/backup/rman/control.bak;

 }

 

  

################################################################
Restore

################################################################

 

1. Restore Datafile, Controlfile, Archived redo log file

 - restore 명령으로 백업set이나 image copy본에서 restore가능하다.

 (image copy본은 disk에서만 가능)

 

2. restore database

 - database restore시에는 db는 항상 close상태이어야 한다. (db open된 상태라면 아래와 같이 shutdown , startup mount 상태로 한다.)

 

     shutdown immediate

     startup mount

 

ex) 기존의 datafile 위치에 database restore 하는경우

 run {

       allocate channel ch1 type disk;

       allocate channel ch2 type disk;

       allocate channel ch2 type disk;

       restore database;

 }

 

3. tablespace datafile restore
3.1 기존위치에 tablespace restore

 run {

        sql ‘alter tablespace example offline ’;

        allocate channel ch1 type disk;

        restore tablespace  example;

 }

 
3.2 새로운 위치에 tablespace restore

 run {

        allocate channel ch1 type disk;

        sql ‘alter tablespace  example offline’ ;

         ## 새로운 위치에 datafile restore

         set newname for datafile ‘/home/oracle/oradata/testdb/example01.dbf’
          
to ‘/home/oracle/temp/example01.dbf’;

         restore tablespace example;

         ## 변경된 위치로 control file이 인식할 수 있게 함

         switch datafile all;

 }


4. control file restore

 - nomount 단계에서 restore 해야함

 run {

       allocate channel ch1 type disk;

       restore controlfile;

       alter database mount;

 }

 

5. Archived redo log restore

 - mount 단계에서 restore

 run {

       ## init.ora 에 명시되어있는 log_archive_dest 위치가 아니 다른 위치에 restore하고자 할때

       set archivelog destination to ‘/oracle/temp_restore’;

       allocate channel ch1 type disk;

       restore archivelog all;

 }

  

################################################################
Recovery

################################################################

1. Complete Recovery
1.1 recover database

 shutdown immediate;

 startup mount;

 

 run {

       allocate channel ch1 type disk;

       restore database;

       recover database;

 }

 
1.2 recover database (control file 백업본을 restore하고 복구하는 경우)

 startup nomount;

 

 run {

        allocate channel ch1 type ‘sbt_tape’;

        restore controlfile;

        alter database mount;

        restore database;

        recover database;

        alter database open resetlogs;

 }

 * resetlogs database open한 경우 reset database명령수행이 필요하며, 다시 database를 백업받는다.

 
1.3. recover tablespace
1.3.1 database close상태이고 tablespace위치에 접근가능할 때

 run {

        allocate channel ch1 type disk;

        restore tablespace tbs_3;

        recover tablespace tbs_3;

 }

 
1.3.2 database close상태이고 tablespace위치에 접근가능하지 못할 때
(datafile 위치를 바꿀 필요가 있을때)

 run {

        allocate channel ch1 type disk;

        set newname for datafile ‘/disk1/oracle/tbs_1.f’ to ‘/disk2/oracle/tbs_1.f’;

        restore tablespace tbs_1;

        switch datafile all;

        recover tablespace tbs_1;

 }

 
1.3.3 database open된 상태이고 tablespace위치에 접근가능할 때

 run {

        sql ‘alter tablespace user_data offline temporary’;

        allocate channel ch1 type disk;

        set archivelog destination to ‘/oracle/temp/arc1_restore’;

        restore tablespace user_data;

        recover tablespace user_data;

        sql ‘alter tablespace user_data online’;

 }


1.3.4 database
open된 상태이고 tablespace위치에 접근불가능할 때

 run {

        sql ‘alter tablespace tbs_1 offline temporary’;

        allocate channel ch1 type disk;

        set newname for datafile ‘/disk1/oracle/tbs_1.f’ to ‘/disk2/oracle/tbs_2.f’;

        restore tablespace tbs_1;

        switch datafile all;

        recover tablespace tbs_1;

        sql ‘alter tablespace tbs_1 online’;

 }


2. Incomplete Recovery
2.1 time base Incomplete Recovery

   time base Incomplete Recovery를 하고자 할 때는 time format을 확인한 후 작업해야 한다.

  (필요시 time format설정 변경)

 

   ) NLS_LANG=american

   NLS_DATE_FORMAT=’Mon DD YYYY HH24:MI:SS’

 

   database open시는 반드시 shutdown후 작업

     shutdown immediate;

     startup mount;

 

 run {

       set until time ‘Nov 15 1998 09:00:00’;

       allocate channel ch1 type ‘sbt_tape’;

       restore database;

       recover databse;

       alter database open resetlogs;

 }

 

   resetlogs database open후 반드시 recovery catalog database reset database 명령으로 초기화 후 target database를 백업 받도록 한다.

 


2.2
특정 SCN까지 recovery

 database open시는 반드시 shutdown후 작업

   shutdown immediate;

   startup mount;

 

 run {

       set until scn 1000;

       allocate channel ch1 type ‘sbt_tape’;

       restore database;

       recover database;

       alter database open resetlogs;

 }

 

   resetlogs database open후 반드시 recovery catalog database reset database 명령으로 초기화 후 target database를 백업 받도록 한다.

 


2.3
특정 log sequence까지 recovery

  어느시점까지 recovery할것인지는 v$log_history view 조회를 통해서 결정

 

   database open시는 반드시 shutdown후 작업

    shutdown immediate;

    startup mount;

 

 ## thread 1에 대해 log sequence 6 까지 recovery하는 예

 run {

       set until logseq 6 on thread 1;

       allocate channel ch1 type ‘sbt_tape’;

       restore database;

       recover database;

       alter database open resetlogs;

 }

  resetlogs database open후 반드시 recovery catalog database reset database 명령으로 초기화 후 target database를 백업 받도록 한다.


3.  recovery catalog
없이 DBPITR(DataBase Point In Time Recovery)할때

 - recovery catalog 없이 DBPITR 수행을 하고자 할때는 아래와 같은 몇가지 필요한 사항들이 있다

 - control file은 별도로 백업을 받아 두도록 한다.

    database 백업시 control file도 자동으로 백업을 받아지기는 하지만 그때 발생한 database 백업에 대한 정보를 가지고 있지 못하기 때문에 별도로 아래와 같이 백업을 받도록 한다.

 

     backup database;

    backup current controlfile tag = ‘database backup’;

 

    controlfile 백업시 tag 옵션을 사용하여 향후에 특정시점에 백업받은 controlfile을 사용할 수 있도록 한다.

 - tablespace 변경 시나 datafile 추가시 백업을 수행하도록 한다.(control file도 포함)

 

 예)

     catalog없이 rman 시작

     rman target / nocatalog

 

     만일 database open된 상태라면 shutdown mount시킨다.

     startup force mount;

 

     특정 임시위치에 control file restore

 run {

        set until time ‘Jun 18 1998 16:32:36’;

        allocate channel ch1 type disk;

        restore controlfile to ‘/tmp/cf.tmp’ from tag = ‘database backup’;

 }

 

 백업받은 특정 controlfile restore할 수 없을 때는 rman을 통해 restore받은 controlfile아래와 같은 sql 명령으로 백업받은 후 init.ora 관련 파라미터를 조정한후 다음단계를 수행하도록 한다.


 - sql > alter database backup controlfile to ‘/tmp/original_cf’;

 - database shutdown

 - init.ora 에 명시된 CONTROL_FILES 파라미터를 적절히 조정

 - 백업받은 controlfile을 적당한 위치에 copy

 - startup mount

 run {

        set until time ‘Jun 18 1998 16:32:36’;

        allocate channel ch1 type disk;

        restore database;

        recover database noredo;                         ## database Noarchive Mode일때 noredo 옵션사용

        alter database open resetlogs;                  ## Archive Mode일때는 noredo 옵션없이 recover한다.

 }


출처 : cafe.naver.com/prodba
반응형

'Database > ORACLE' 카테고리의 다른 글

오라클 클론 디비로 복구 하기  (0) 2010.07.13
PL/SQL Exception  (0) 2010.07.06
오라클 암호화 기능  (0) 2010.07.02
오라클 pump 관련 자료  (0) 2010.06.30
오라클 기본 유저 정보  (0) 2010.06.30
반응형

복구 관리자 (recovery manager:rman)는 데이터베이스의 백업과 복구에 관련된 정보를 저장하고 필요한 경우 백업과 복구 절차를 수행해 주는 유틸리티이다. 데이터베이스, 테이블스페이스, 데이터파일, 컨트롤 파일, 아카이브 파일별로 백업할 수 있으며, 백업 시 사용되지 않는 블록을 제외하고 백업할 수 도 있다. 또한 백업 시 손상된 블록의 사용 가능 여부를 확인해 주기도 한다.

rman 툴은 자체적인 스크립트 해석 인터프리터를 가진 명령언어 인터프리터(command language interpreter)이므로 입력된 명령을 해석하여 실행하게 된다. 예를 들어, backup, restore, copy, recover와 같은 명령을 rman 툴에서 실행할 수 있는 것이다.

rman의 형식은 다음과 같다.

형식

RMAN  [TARGET connectStringSpec
      ¦ { CATALOG connectStringSpec }
      ¦ LOG ['] filename ['] [APPEND ]
      ......
      ]...
      
connectStringSpec::=
  ['] [userid] [/ [password]] [@net_service_name] ['] 




rman 구성

RMAN 시작과 DB에 연결
다음 예제는 간단하게 rman에 접속하고 접속해지 하는 과정이다.
【예제】 ☜ rman 시각과 끝
$ rman

RMAN> exit

$ 
SQL*Plus로 데이터베이스에 접속하듯이 RMAN으로도 데이터베이스에 접속하는데,
그 차이점은 RMAN은 SYSDBA 권한을 가지고 타킷과 보조 데이터베이스에 접속해야 하는데 AS SYSDBA 키워드는 사용하지 않아도 묵시적으로 가진 것으로 간주하기 때문에 의도적으로 표시하지 않아도 된다는 점만 다르다.

RMAN에 연결되면 CONNECT TARGET을 실행해야 타킷 데이터베이스에 접속이 이루어진다.

【예제】☜ target DB에 관리자로 접속 
$ rman

RMAN> connect target /

connected to target database: ORCL (DBID=1204356616)

RMAN> exit

Recovery Manager complete.
$
다음 예는 RMAN 세션중에 출력되는 텍스트 파일을 로그 파일(/tmp/msglog.log)에 추가하도록 하는 예제이다.
【예제】☜ log 파일을 지정하면서 접속 
$ rman TARGET / LOG /tmp/msglog.log APPEND
RMAN> exit
$
이처럼 rman 툴을 이용하여 rman 클라이언트로 들어간 다음에, rman> 프롬프트에서 입력되는 명령은 그 문장의 끝에 세미콜론(;)을 붙여야 하는데, 다만 예외로 STARTUP, SHUTDOWN, CONNECT 명령은 세미콜론을 붙여도 되고 안 붙여도 된다

【예제】

RMAN> CONNECT TARGET
RMAN> BACKUP DATABASE;

RMAN> BACKUP DATABASE
2>  INCLUDE CURRENT
3>  CONTROLFILE
4>  ;
디폴트 RMAN configuration 보기

RMAN이 백업과 복구를 실행하는 구성을 미리 작성한 디폴트 configure가 준비되어 적용된다.
configure란 백업장치를 지정하고, 백업 장치에 접속(이를 channel이라 부름)의 구성을 설정하는 것이다.
현재 작성된 configure를 다음과 같이 확인할 수 있다.

1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET /

2) SHOW ALL 명령을 실행한다.
RMAN> SHOW ALL;


$ rman TARGET /
RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/export/home/oracle/app/oracle/product/110.1/dbs/snapcf_orcl.f'; # default

RMAN> 

나열되는 항목은 CONFIGURE 명령으로 재작성할 수 있으며, 다음은 channel를 configure하는 예시이다.

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # backup goes to disk
CONFIGURE DEVICE TYPE sbt PARALLELISM 2; # 2 channels used in in channel
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/disk1/%U' # 1st channel to disk1
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/disk2/%U' # 2nd channel to disk2
BACKUP DATABASE; # backup - 1st channel goes to disk1 and 2nd to disk2

데이터베이스 백업

BACKUP 명령으로 파일을 백업한다. RMAN은 configure로 설정된 장치에 데이터를 백업하는데, 디폴트는 disk이다.
flash recovery가 가능하고 FORMAT 매개변수를 지정하지 않은 경우라면, RMAN은 recovery 영역에 unique한 이름으로 자동적으로 백업을 생성한다.
RMAN은 디폴트로 image copy보다는 백업 셋을 생성하는데, 여기서 image copy란 유닉스의 cp 명령어로 복사하는 것을 image copy 라 한다.
backup set은 하나 이상의 backup piece로 RMAN으로만 억세스할 수 있도록 물리적 파일을 복사하는 것을 뜻한다.

BACKUP AS COPY 명령은 데이터베이스 파일을 디스크에 bit-for-bit로 image copy를 수행하는데 이는 RMAN에서만 이용할 수 있다.

option 예제 설명
FORMAT
BACKUP
 FORMAT 'AL_%d/%t/%s/%p'
 ARCHIVELOG LIKE '%arc_dest%';
백업할 조각의 위치와 이름을 지정함
%U : 유일한 이름
%d : DB_NAME
%t : timestamp를 가짐
%s : number를 가짐
%p : backup piece number
TAG
BACKUP
 TAG 'weekly_full_db-bkup'
 DATABASE MAXSETSIZE 10M;
백업 라벨에 사용자 정의 문자로 지정하지만,
TAG을 지정하지 않으면 date와 time이 디촐트임

【예제】☜ 데이터베이스를 백업

ARCHIVELOG 모드
1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET / 2) BACKUP DATABASE 명령을 실행한다.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
NOARCHIVELOG 모드
데이터베이스는 반드시 mount 상태이어야 한다.

1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET / 2) shutdown하고 mount한다.
RMAN> SHUTDOWN IMMEDIATE
RMAN> STARTUP FORCE DBA;
RMAN> SHUTDOWN IMMEDIATE
RMAN> STARTUP MOUNT; 3) BACKUP DATABASE를 실행한다.(아래 둘 중 하나)
RMAN> BACKUP DATABASE;
RMAN> BACKUP AS COPY DATABASE; 4) 데이터베이스를 open한다.
RMAN> ALTER DATABASE OPEN;

앞 예제에서와 같이 archive mode와 noarchive mode을 예제로 익혔다.

incremental backup

incremental backup은 BACKUP INCREMENTAL 명령을 사용하여 실행하는데, 이는 full database backup보다 더 빠르다.
그러므로 recovery도 redo logs만 사용하는 경우보다 더 신속하게 복구할 수 있다.
incremental backup이나 full backup 모두 level 0의 내용은 동일하지만, full backup과 달리 level 0 backup은 incremental backup에 관한 사항이 담겨있다.
level 1 incremental backup은 이전의 incremental backup 이후의 변경된 내용만 담긴다.
그래서 level 1 백업을 cumulative incremental backup이라하고, level 0 백업을 differential incremental backup이라하는데, differential이 디폴트이다.

【예제】☜ 데이터베이스의 incremental 백업
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) BACKUP INCREMENTAL 명령을 실행한다.
다음은 level 0 incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;

다음은 level 1 cumulative incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

다음은 level 1 differential incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

incrementally updated backup

incrementally updated 백업은 BACKUP FOR RECOVER OF COPY 명령을 사용한다.
FOR RECOVER OF COPY 문의 옵션은 다음과 같다.

option 예제
FOR RECOVER OF COPY WITH TAG 'tag_name' BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE;
FOR RECOVER OF COPY DATAFILECOPY FORMAT 'format' BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY DATAFILECOPY FORMAT 'disk2/df1.cpy' DATABASE;

【예제】☜ 데이터베이스의 incrementally updated 백업
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) RECOVER COPY와 BACKUP INCREMENTAL 명령을 실행한다.
다음 스크립트를 실행한다.


     RECOVER COPY OF DATABASE
       WITH TAG 'incr_update';
     BACKUP
       INCREMENTAL LEVEL 1
       FOR RECOVER OF COPY WITH TAG 'incr_update'
       DATABASE;

database 파일과 백업의 validating

VALIDATE 명령을 사용하여 모든 데이터베이스 파일이 존재를 확인하고, 바른 위치에 있는지 확인하며, 또한 물리적 오류의 여지를 확인한다.
CHECK LOGICAL옵션을 사용하여 논리적 오류도 확인할 수 있다.

【예제】☜ 데이터베이스 파일의 유효성 확인
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) VALIDATE 명령을 해당파일에 실행한다.

   BACKUP VALIDATE CHECK LOGICAL
     DATABASE ARCHIVELOG ALL;
만약 각각의 블럭에 대한 유효성 체크는 다음과 같이 할 수 있다.

VALIDATE DATAFILE 4 BLOCK 10 TO 13;

다음은 백업셋에 대한 유효성 체크의 예이며, 백업셋은 LIST BACKUP를 실행하여 확인할 수 있다.

VALIDATE BACKUPSET 3;

RMAN에 동작하는 명령어로 구성된 파일

데이터베이스를 주기적으로 반복하여 백업한다는 것은 실증하기 때문에 이러한 동작을 RMAN 명령으로 작성한 명령 파일을 하나의 스크립트로 작성하여 @아규먼트와 파일이름을 지정하여 실행 시키면 편리하다.

【예제】☜ RMAN에서 동작할 스크립트 생성과 실행
1) vi와 같은 문서편집기로 RMAN 명령문으로 구성된 파일을 작성한다.


    #my_commnad_file.txt
    BACKUP DATABASE PLUS ARCHIVELOG;
    LIST BACKUP;
    EXIT;

2) RMAN을 구동하고 작성한 스크립트를 @ 아규먼트로 실행시킨다.

구 분 명령어 실행 실행 결과
방법1 $ rman TARGET / @my_command_file.txt 실행이 완료되면 RMAN에서 exit함
방법2 RMAN> @my_command_file.txt **end-of-file** 메시지가 출력되며 RMAN에서 exit하지 않음

작성되는 명령문 스크립트에서 비실행문은 #으로 시작되고 또한 중간에 #을 넣으면 #이하는 비실행으로 처리한다.
rman 프롬프트에서 명령을 입력할 때도 #이하는 비실행문으로 처리한다

【예제】☜
RMAN> BACKUP # 이 부분부터 줄 끝까지는 비실행임
2> SPFILE;

Starting backup at 04-JAN-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-JAN-10
channel ORA_DISK_1: finished piece 1 at 04-JAN-10
piece handle=/export/home/oracle/flash_recovery_area/ORCL/backupset/2010_01_04/o1_mf_nnsnf_TAG20100104T130430_5n2t6gt7_.bkp tag=TAG20100104T130430 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-JAN-10

RMAN>

RMAN 동작의 레포트

RMAN의 LISTREPORT 문을 사용하여 RMAN을 사용한 백업 상태에 대한 정보를 알 수 있고, SHOW ALL 문을 사용하여 configuration에 대한 정보를 확인할 수 있다.

백업정보 list

LIST BACKUPLIST COPY 문을 사용하여 백업과 데이터파일에 대한 정보를 나타낸다.
다음 표는 백업에 대한 LIST 문의 옵션이다.

option 예제 설명
BY BACKUP LIST BACKUP OF DATABASE BY BACKUP 백업셋의 출력으로 디폴트임
BY FILE LIST BACKUP BY FILE 백업된 파일에 대한 정보
SUMMARY LIST BACKUP SUMMARY 요약이 출력되는데 디폴트이며 출력은 VERBOSE임
EXPIRED LIST EXPIRED COPY RMAN에의 해 기록된 백업에 관한 목록이지만, 최근 CROSSCHECK 문에 의한 것은 제외함
RECOVERABLE LIST BACKUP RECOVERABLE AVAILABLE 상태에 있는 datafile이 backup, copy된 사항이 나열됨

【예제】☜ LIST BACKUP/COPY 실행
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) LIST 문을 실행한다.

RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST COPY OF DATAFILE 1,2;
RMAN> LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 10;
RMAN> LIST BACKUPSET OF DATAFILE;

데이터베이스 파일과 백업에 관한 REPORT

REPORT 문을 실행하여 LIST 문보다 더 다양한 정보를 알 수 있다.
다음은 REPORT 문의 옵션이다.

option 예제 설명
NEED BACKUP REPORT NEED BACKUP DATABASE 백업해야할 파일을 보임, 추가적으로 REDUNDANCY, RECOVERY WINDOW 를 사용할 수 있음
OBSOLETE REPORT OBSOLETE backup retention policy로 구성된 쓸모없는(폐기된) 백업을 나열함
SCHEMA REPORT SCHEMA 데이터베이스 내의 테이블스페이스와 데이터파일을 출력
UNRECOVERABLE REPORT UNRECOVERABLE 최근의 데이터파일 백업에서 복구될수 없는 데이터파일을 출력

【예제】☜
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) REPORT 문을 실행한다.

RMAN> REPORT SCHEMA;
RMAN> REPORT OBSOLETE;

RMAN 백업 Maintaining

타킷 데이터베이스의 control 파일에 저장된 RMAN의 정보가 RMAN maintence command에 의해 사용된다.

Crosschecking backup

CROSSCHECK 명령에 의해 RMAN에 의해 백업된 논리적 기록물과 저장매체에 있는 파일을 동기화한다.

【예제】☜ crosscheck all backups & copies on disk
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) CROSSCHECK 문을 실행한다.

RMAN> CROSSCHECK BACKUP;
RMAN> CROSSCHECK COPY;

Delete Obsolete Backups

DELETE 명령으로 RMAN으로 디스크나 테이프에 백업하였지만 쓸모없는 백업이나 파일을 삭제하게 된다.

control 파일의 파일 상태를 DELETED로 갱신하고, NOPROMPT를 지정하지 않으면 삭제할 때 의지를 묻게된다.
DELETE OBSOLETE 명령은 더 이상 필요없는 백업이나 복사된 파일을 지울 때 사용된다.

【예제】☜ delete obsolete backups & copies
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) DELETE OBSOLETE 문을 실행한다.

RMAN> DELETE OBSOLETE;

Diagnosing & Repairing Failures with Data Recovery Advisor

data recovery advisor를 이용하여 간단하게 데이터베이스의 문제점을 진단하고 수리할 수 있다.

Listing Failures & Determing Repair Options

Failure란 데이터의 오염(corruption)을 의미한다. failure에는 fail priorityfailure status가 있는데, priority에는 CRITICAL, HIGH, LOW가 있으며, 상태는 OPEN이나 CLOSED일 수 있다.

LIST FAILURE : 모든 종류의 failure를 출력
ADVISE FAILURE : repair option으로 수동과 자동을 결정

【예제】☜ LIST FAILURE & ADVISE FAILURE
RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

RMAN> LIST FAILURE;
RMAN> ADVISE FAILURE;

Repairing Failures

앞의 LIST FAILURE나 ADVISE FAILURE를 실행하고 나서 REPAIR FAILURE 명령으로 수리할 수 있다.

【예제】☜ REPAIR FAILURE
RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

RMAN> REPAIR FAILURE;

Flashback Database

데이터베이스를 과거 어느 시점으로 되돌리는 것으로 이는 미디어 복구와 달리데이터파일을 restore할 필요가 없다.
FLASHBACK DATABASE 명령을 사용하면 과거 어느 시점으로 되돌릴 수 있는데, 이 기능은 반드시 데이터베이스가 mount 되어 있어야 한다.

【예제】☜ Flashback database
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 데이터베이스가 mount 되어 있어야 한다.

RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;

3) FLASHBACK DATABASE를 다음중 하나를 실행한다.


SQL> select name,scn, time, database_incarnation#,
  2  guarantee_flashback_database
  3  from v$restore_point
  4  where guarantee_flashback_database='YES';

RMAN> FLASHBACK DATABASE TO SCN 86115;
RMAN> FLASHBACK DATABASE TO RESTORE POINT BEFORE_CHANGE;
RMAN> FLASHBACK DATABASE TO TIME "TO_DATE('11/20/10','MM/DD/YY')";

4) 데이터베이스를 SQL*Plus에서 검증하기 위해 open한다.

RMAN> SQL "ALTER DATABASE OPEN READ ONLY";

5) 데이터베이스를 open한다.

RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;
RMAN> ALTER DATABASE OPEN RESETLOGS;

Restore & Recover Database Files

RESTORE나 RECOVER 명령으로 데이터베이스 파일을 복구할 수 있다.

데이터베이스 파일 복구 준비

RESTORE ... PREVIEW 명령으로 사전에 미리보기를 하지만 RESTORE는 실행되지 않는다.

【예제】☜ Preview a database restore & recovery
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 필요한 경우라면 테이블스페이스와 데이터파일을 확인한다.

RMAN> REPORT SCHEMA;

3) RESTORE DATABASE 명령에 PREVIEW 옵션을 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

데이터베이스 전체를 recover

RESTORE DATABASE와 RECOVER DATABASE 명령을 사용하여 데이터베이스 전체를 복구할 수 있다.

【예제】☜ Recover whole database
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 파일 복구 준비를 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

3) 데이터베이스를 mount 상태로 만든다.

RMAN> STARTUP FORCE MOUNT;

4) 데이터베이스를 restore한다.

RMAN> RESTORE DATABASE;

5) 데이터베이스를 recover한다.

RMAN> RECOVER DATABASE;

6) 데이터베이스를 open한다.

RMAN> ALTER DATABASE OPEN;

테이블스페이스만 recover

RESTORE TABLESPACE와 RECOVER TABLESPACE 명령을 사용하여 필요한 테이블스페이스만 복구할 수 있다.
데이터파일을 새 위치에 restore할 수 없다면, SET NEWNAME 명령을 RUN하고 SWITCH DATAFILE 명령이나 또는 ALTER DATABASE RENAME FILE 문으로 control file을 갱신할 수 있다.

【예제】☜ Recover tablespace when the database is open
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 파일 복구 준비를 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

3) OFFLINE 복구를 준비한다.(예: 테이블스페이스 이름::=users)

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';

4) 테이블스페이스를 restore와 recover 한다.

RMAN>

     RUN 
        {
         SET NEWNAME FOR DATAFILE '/disk1/oradata/prod/users01.dbf'
           TO '/disk2/users01.dbf';
         RESTORE TABLESPACE users;
         SWITCH DATAFILE ALL;
         RECOVER TABLESPACE users;
        }

5) 테이블스페이스를 ONLINE한다.

RMAN> SQL 'ALTER TABLESPACE users ONLINE';

이 방법외에 RESTORE DATAFILERECOVER DATAFILE을 사용하여 데이터파일 레벨로 복구할 수 도 있다.

데이터 블럭(block)별로 recover

잘못된 데이터파일 블럭 단위로 복구도 가능한데, v$database_block_corruption 뷰에서 오류된 데이터 파일 블럭을 확인할 수 있다.

【예제】☜ Recover data blocks
1) SQLPlus에서 오류된 데이터블럭 번호를 확인한다.

SQL> SELECT NAME, VALUE FROM V$DIAG_INFO

2) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

3) RECOVER 명령을 실행하여 블럭을 수리한다.

RMAN> RECOVER CORRUPTION LIST;

개별 블럭을 수리하려면 다음과 같이 실행한다.

RMAN> RECOVER DATAFILE 1 BLOCK 233, 235 DATAFILE 2 BLOCK 100 TO 200;


출처 : http://radiocom.kunsan.ac.kr/lecture/oracle/backup_restore/rman.html

반응형

+ Recent posts