'오라클 백업'에 해당되는 글 1건
- 2023.12.06 오라클 백업(Datapump) 간단한 사용 방법 2
Oracle Datapump 백업 사용 방법
작업 환경:
OS: Oracle Linux 8.9
DB: Oracle 19c
Datapump 백업은 사용 방법이 간단하기 때문에 실무에서 많이 사용합니다.
특히 개발DB 데이터 이관, 테이블 부분 이관, 계정 단위 이관에 사용하며 오라클을 사용한다면 꼭 익혀두시는게 좋습니다.
Datapump 장점:
- 백업 방법이 간단하다.
- Parallel(병렬)로 매우 빠르게 백업이 가능하다.
- 테이블 단위, 오브젝트 단위, 테이블 데이터 없이 스크립트만 백업 가능
Datapump 단점:
- 시점 복구 불가
작업 스크립트 예제
1. 백업 디렉터리 생성 및 권한 변경
- Linux에서 실행
- root 계정
mkdir /BACKUP
chown oracle.dba /BACKUP
2. 오라클 백업 디렉터리 생성
- sqlplus / as sysdba 실행
-- 백업 디렉터리 생성
CREATE OR REPLACE DIRECTORY DB_DUMP AS '/BACKUP';
-- 권한 생성
GRANT READ, WRITE ON DIRECTORY SYS.DB_DUMP TO PUBLIC;
-- 백업 디렉터리 생성 확인
SELECT * FROM DBA_DIRECTORIES
WHERE DIRECTORY_NAME = 'DB_DUMP';
3. Datapump 백업
- system 계정(암호 oracle) 기준으로 작성되었습니다.
- 백업 일자는 2023/01/01 백업할때 일자는 변경해서 사용해주세요.
- 전체 백업
expdp system/oracle DIRECTORY=DB_DUMP FULL=YES \
DUMPFILE=EXPDP_DB_FULL_20230101.dmp LOGFILE=EXPDP_DB_FULL_20230101.log
- 전체 백업(Parallel 4) 병렬 처리
expdp system/oracle DIRECTORY=DB_DUMP FULL=YES PARALLEL=4 \
DUMPFILE=EXPDP_DB_FULL_20230101_%U.dmp LOGFILE=EXPDP_DB_FULL_20230101.log
- DB 특정 계정 백업
- DB계정명: DBTEST
expdp system/oracle DIRECTORY=DB_DUMP SCHEMAS=DBTEST \
DUMPFILE=EXPDP_DB_ DBTEST _20230101.dmp LOGFILE=EXPDP_DB_ DBTEST _20230101.log
- 테이블 단위 백업
- DB계정명: DBTEST
- 테이블명: CUST
expdp system/oracle DIRECTORY=DB_DUMP \
DUMPFILE= EXPDP_DBTEST_CUST_20230101.dmp LOGFILE=EXPDP_DBTEST_CUST_20220103.log \
TABLES=DBTEST.CUST
작업 실행 결과
-- LINUX(root 계정 실행) [root@db /]# mkdir /BACKUP [root@db /]# chown oracle.dba /BACKUP [root@db /]# ls -ld /BACKUP drwxr-xr-x. 2 oracle dba 6 Dec 6 10:36 /BACKUP -- sqlplus(oracle 계정 실행) [oracle@db ~]$ sqlplus / as sysdba SQL> CREATE OR REPLACE DIRECTORY DB_DUMP AS '/BACKUP'; Directory created. SQL> GRANT READ, WRITE ON DIRECTORY SYS.DB_DUMP TO PUBLIC; Grant succeeded. SQL> col owner for a10 SQL> col DIRECTORY_NAME for a10 SQL> col DIRECTORY_PATH for a10 SQL> SELECT * FROM DBA_DIRECTORIES WHERE DIRECTORY_NAME = 'DB_DUMP'; OWNER DIRECTORY DIRECTORY ORIGIN_CON_ID ---------- ---------- ---------- ------------- SYS DB_DUMP /BACKUP 0 -- Datapump 전체 백업(oracle 계정 실행) [oracle@db ~]$ expdp system/oracle DIRECTORY=DB_DUMP FULL=YES \ > DUMPFILE=EXPDP_DB_FULL_20230101.dmp LOGFILE=EXPDP_DB_FULL_20230101.log Export: Release 19.0.0.0.0 - Production on Wed Dec 6 10:42:28 2023 Version 19.3.0.0.0 Copyright (c) 1982, 2023, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Starting "SYSTEM"."SYS_EXPORT_FULL_01": system/******** DIRECTORY=DB_DUMP FULL=YES DUMPFILE=EXPDP_DB_FULL_20230101.dmp LOGFILE=EXPDP_DB_FULL_20230101.log Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER Processing object type DATABASE_EXPORT/TABLESPACE Processing object type DATABASE_EXPORT/PROFILE Processing object type DATABASE_EXPORT/RADM_FPTM Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE Processing object type DATABASE_EXPORT/SCHEMA/ON_USER_GRANT Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA Processing object type DATABASE_EXPORT/RESOURCE_COST Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK Processing object type DATABASE_EXPORT/DIRECTORY/DIRECTORY Processing object type DATABASE_EXPORT/DIRECTORY/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PROCOBJ Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE Processing object type DATABASE_EXPORT/EARLY_POST_INSTANCE_IMPCALLOUT/MARKER Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE Processing object type DATABASE_EXPORT/NORMAL_POST_INSTANCE_IMPCALLOUT/MARKER Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE Processing object type DATABASE_EXPORT/SCHEMA/TABLE/COMMENT Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX Processing object type DATABASE_EXPORT/FINAL_POST_INSTANCE_IMPCALLOUT/MARKER Processing object type DATABASE_EXPORT/AUDIT_UNIFIED/AUDIT_POLICY_ENABLE Processing object type DATABASE_EXPORT/POST_SYSTEM_IMPCALLOUT/MARKER . . exported "SYS"."KU$_USER_MAPPING_VIEW" 6.062 KB 36 rows . . exported "AUDSYS"."AUD$UNIFIED":"SYS_P201" 6.021 MB 1608 rows . . exported "AUDSYS"."AUD$UNIFIED":"SYS_P281" 55.14 KB 12 rows . . exported "SYSTEM"."REDO_DB" 25.59 KB 1 rows . . exported "WMSYS"."WM$WORKSPACES_TABLE$" 12.10 KB 1 rows . . exported "WMSYS"."WM$HINT_TABLE$" 9.984 KB 97 rows . . exported "LBACSYS"."OLS$INSTALLATIONS" 6.960 KB 2 rows . . exported "WMSYS"."WM$WORKSPACE_PRIV_TABLE$" 7.078 KB 11 rows . . exported "SYS"."DAM_CONFIG_PARAM$" 6.531 KB 14 rows . . exported "SYS"."TSDP_SUBPOL$" 6.328 KB 1 rows . . exported "WMSYS"."WM$NEXTVER_TABLE$" 6.375 KB 1 rows . . exported "LBACSYS"."OLS$PROPS" 6.234 KB 5 rows . . exported "WMSYS"."WM$ENV_VARS$" 6.015 KB 3 rows . . exported "SYS"."TSDP_PARAMETER$" 5.953 KB 1 rows . . exported "SYS"."TSDP_POLICY$" 5.921 KB 1 rows . . exported "WMSYS"."WM$VERSION_HIERARCHY_TABLE$" 5.984 KB 1 rows . . exported "WMSYS"."WM$EVENTS_INFO$" 5.812 KB 12 rows . . exported "LBACSYS"."OLS$AUDIT_ACTIONS" 5.757 KB 8 rows . . exported "LBACSYS"."OLS$DIP_EVENTS" 5.539 KB 2 rows . . exported "AUDSYS"."AUD$UNIFIED":"AUD_UNIFIED_P0" 0 KB 0 rows . . exported "LBACSYS"."OLS$AUDIT" 0 KB 0 rows . . exported "LBACSYS"."OLS$COMPARTMENTS" 0 KB 0 rows . . exported "LBACSYS"."OLS$DIP_DEBUG" 0 KB 0 rows . . exported "LBACSYS"."OLS$GROUPS" 0 KB 0 rows . . exported "LBACSYS"."OLS$LAB" 0 KB 0 rows . . exported "LBACSYS"."OLS$LEVELS" 0 KB 0 rows . . exported "LBACSYS"."OLS$POL" 0 KB 0 rows . . exported "LBACSYS"."OLS$POLICY_ADMIN" 0 KB 0 rows . . exported "LBACSYS"."OLS$POLS" 0 KB 0 rows . . exported "LBACSYS"."OLS$POLT" 0 KB 0 rows . . exported "LBACSYS"."OLS$PROFILE" 0 KB 0 rows . . exported "LBACSYS"."OLS$PROFILES" 0 KB 0 rows . . exported "LBACSYS"."OLS$PROG" 0 KB 0 rows . . exported "LBACSYS"."OLS$SESSINFO" 0 KB 0 rows . . exported "LBACSYS"."OLS$USER" 0 KB 0 rows . . exported "LBACSYS"."OLS$USER_COMPARTMENTS" 0 KB 0 rows . . exported "LBACSYS"."OLS$USER_GROUPS" 0 KB 0 rows . . exported "LBACSYS"."OLS$USER_LEVELS" 0 KB 0 rows . . exported "SYS"."AUD$" 0 KB 0 rows . . exported "SYS"."DAM_CLEANUP_EVENTS$" 0 KB 0 rows . . exported "SYS"."DAM_CLEANUP_JOBS$" 0 KB 0 rows . . exported "SYS"."TSDP_ASSOCIATION$" 0 KB 0 rows . . exported "SYS"."TSDP_CONDITION$" 0 KB 0 rows . . exported "SYS"."TSDP_FEATURE_POLICY$" 0 KB 0 rows . . exported "SYS"."TSDP_PROTECTION$" 0 KB 0 rows . . exported "SYS"."TSDP_SENSITIVE_DATA$" 0 KB 0 rows . . exported "SYS"."TSDP_SENSITIVE_TYPE$" 0 KB 0 rows . . exported "SYS"."TSDP_SOURCE$" 0 KB 0 rows . . exported "SYSTEM"."REDO_LOG" 0 KB 0 rows . . exported "WMSYS"."WM$BATCH_COMPRESSIBLE_TABLES$" 0 KB 0 rows . . exported "WMSYS"."WM$CONSTRAINTS_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$CONS_COLUMNS$" 0 KB 0 rows . . exported "WMSYS"."WM$LOCKROWS_INFO$" 0 KB 0 rows . . exported "WMSYS"."WM$MODIFIED_TABLES$" 0 KB 0 rows . . exported "WMSYS"."WM$MP_GRAPH_WORKSPACES_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$MP_PARENT_WORKSPACES_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$NESTED_COLUMNS_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$RESOLVE_WORKSPACES_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$RIC_LOCKING_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$RIC_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$RIC_TRIGGERS_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$UDTRIG_DISPATCH_PROCS$" 0 KB 0 rows . . exported "WMSYS"."WM$UDTRIG_INFO$" 0 KB 0 rows . . exported "WMSYS"."WM$VERSION_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$VT_ERRORS_TABLE$" 0 KB 0 rows . . exported "WMSYS"."WM$WORKSPACE_SAVEPOINTS_TABLE$" 0 KB 0 rows . . exported "MDSYS"."RDF_PARAM$" 6.515 KB 3 rows . . exported "SYS"."AUDTAB$TBS$FOR_EXPORT" 5.960 KB 2 rows . . exported "SYS"."DBA_SENSITIVE_DATA" 0 KB 0 rows . . exported "SYS"."DBA_TSDP_POLICY_PROTECTION" 0 KB 0 rows . . exported "SYS"."FGA_LOG$FOR_EXPORT" 0 KB 0 rows . . exported "SYS"."NACL$_ACE_EXP" 0 KB 0 rows . . exported "SYS"."NACL$_HOST_EXP" 6.976 KB 2 rows . . exported "SYS"."NACL$_WALLET_EXP" 0 KB 0 rows . . exported "SYS"."SQL$TEXT_DATAPUMP" 0 KB 0 rows . . exported "SYS"."SQL$_DATAPUMP" 0 KB 0 rows . . exported "SYS"."SQLOBJ$AUXDATA_DATAPUMP" 0 KB 0 rows . . exported "SYS"."SQLOBJ$DATA_DATAPUMP" 0 KB 0 rows . . exported "SYS"."SQLOBJ$PLAN_DATAPUMP" 0 KB 0 rows . . exported "SYS"."SQLOBJ$_DATAPUMP" 0 KB 0 rows . . exported "SYSTEM"."SCHEDULER_JOB_ARGS" 0 KB 0 rows . . exported "SYSTEM"."SCHEDULER_PROGRAM_ARGS" 0 KB 0 rows . . exported "WMSYS"."WM$EXP_MAP" 7.718 KB 3 rows . . exported "WMSYS"."WM$METADATA_MAP" 0 KB 0 rows Master table "SYSTEM"."SYS_EXPORT_FULL_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is: /BACKUP/EXPDP_DB_FULL_20230101.dmp Job "SYSTEM"."SYS_EXPORT_FULL_01" successfully completed at Wed Dec 6 10:43:11 2023 elapsed 0 00:00:42 |