본문 바로가기

DBMS/ORACLE

RMAN 백업

반응형

개요

RMAN 의 다양한 명령어들을 예를 통해서 알아보자.

구성환경

oracle 19c

 

1. rman 접속

#rman target /    => Recovey Catalog  대신  Controlfile을 사용해서 접속

#rman TARGET / CATALOG rman/cat@catdb => Recovery Catalog  사용

 

2. RMAN 백업 예제

예) 데이타베이스 full 백업

RMAN> backup database ;

or

RMAN> backup incremental level 0 database ;

* incremental 0은 full 백업을 지칭하며, 0과 full의 차이는 백업저장소에 0으로 표시된다는 것이다.

 

예) 데이터베이스 incremetal 백업

RMAN> backup incremental level 1 database ;

 

예) 데이터베이스 백업 포맷(/orabackup 디렉토리 하위에 저장) 변경

RMAN> backup format '/orabackup/%d_%T_%t.bk' database ;

* Format spec은 하단 참조

 

예) 백업 리스트 조회

RMAN> list backup ;

or list backup summary ;

 

예) 백업 삭제

RMAN> delete backup ;

 

예) 데이터베이스및 아카이브로그 백업

RMAN> backup database plus archivelog  ;

 

예) 데이터베이스, 아카이브로그 백업후 아카이브로그 삭제

RMAN> run {

backup database ;

backup archivelog all delete input ;

}

 

예) 아카이브 백업후 특정 날짜(14일)전의 아카이브 로그 삭제

RMAN> run {

backup archivelog all ; 

delete noprompt archivelog until time 'sysdate -14' ;

}

 

예) 특정 일자 사이의 아카이브 로그 백업

RMAN> BACKUP ARCHIVELOG FROM TIME 'SYSDATE-30' UNTIL TIME 'SYSDATE-7';

 

예) 실제 저장소의 백업과 catalog의 목록이 일치하지 않을때

RMAN> crosscheck backupset ;

RMAN> delete backupset ;

 

예) 아카이브로그 삭제(아카이브로그 백업없이 삭제)

RMAN> delete archivelog all ;

 

** 참조 : 백업 FORMAT 스펙

docs.oracle.com/html/E10643_07/rcmsubcl010.htm

Syntax Element Description
%a Specifies the activation ID of the database.
%b Specifies the file name stripped of directory paths. It is only valid for SET NEWNAME and backup when producing image copies It yields errors if used as a format specification for a backup that produces backup pieces.
%c Specifies the copy number of the backup piece within a set of duplexed backup pieces. If you did not duplex a backup, then this variable is 1 for backup sets and 0 for proxy copies. If a command is enabled, then the variable shows the copy number. The maximum value for %c is 256.
%d Specifies the name of the database (see Example 4-22).
%D Specifies the current day of the month from the Gregorian calendar in format DD.
%e Specifies the archived log sequence number.
%f Specifies the absolute file number (see Example 4-22).
%F Combines the DBID, day, month, year, and sequence into a unique and repeatable generated name. This variable translates into c-IIIIIIIIII-YYYYMMDD-QQ, where:
  • IIIIIIIIII stands for the DBID. The DBID is printed in decimal so that it can be easily associated with the target database.
  • YYYYMMDD is a time stamp in the Gregorian calendar of the day the backup is generated
  • QQ is the sequence in hexadecimal number that starts with 00 and has a maximum of 'FF' (256)
%h Specifies the archived redo log thread number.
%I Specifies the DBID.
%M Specifies the month in the Gregorian calendar in format MM.
%N Specifies the tablespace name. This substitution variable is only valid when backing up data files as image copies.
%n Specifies the name of the database, padded on the right with x characters to a total length of eight characters. For example, if prod1 is the database name, then the padded name is prod1xxx.
%p Specifies the piece number within the backup set. This value starts at 1 for each backup set and is incremented by 1 as each backup piece is created.Note: If you specify PROXY, then the %p variable must be included in the FORMAT string either explicitly or implicitly within %U.
%s Specifies the backup set number. This number is a counter in the control file that is incremented for each backup set. The counter value starts at 1 and is unique for the lifetime of the control file. If you restore a backup control file, then duplicate values can result. Also, CREATE CONTROLFILE initializes the counter back to 1.
%t Specifies the backup set time stamp, which is a 4-byte value derived as the number of seconds elapsed since a fixed reference time. You can use a combination of %s and %t to form a unique name for the backup set.
%T Specifies the year, month, and day in the Gregorian calendar in this format: YYYYMMDD.
%u Specifies an 8-character name constituted by compressed representations of the backup set or image copy number and the time the backup set or image copy was created.
%U Specifies a system-generated unique file name (default).The meaning of %U is different for image copies and backup pieces. For a backup piece, %U specifies a convenient shorthand for %u_%p_%c that guarantees uniqueness in generated backup file names. For an image copy of a data file, %U means the following:
data-D-%d_id-%I_TS-%N_FNO-%f_%u
For an image copy of an archived redo log, %U means the following:
arch-D_%d-id-%I_S-%e_T-%h_A-%a_%u
For an image copy of a control file, %U means the following:
cf-D_%d-id-%I_%u
%Y Specifies the year in this format: YYYY.
%% Specifies the percent (%) character. For example, %%Y translates to the string %Y.

 

반응형