DM7使用DMRMAN工具删除备份集

使用DMRMAN工具删除备份集
备份集删除是备份管理的主要功能,下面主要对如何删除备份进行描述。内容包括:
1. 概述
2. 删除备份集

1. 概述
DMRMAN中使用REMOVE命令删除备份集,可删除指定备份集,也可批量删除备份集。单个备份集删除时并行备份中的子备份集不允许单独删除;在指定备份集搜集目录中,发现存在引用目标备份集作为基备份的需要执行级联删除,默认报错。批量删除备份集时,跳过收集到的单独的子备份集。语法如下:

REMOVE BACKUPSET '< 备份集目录>'
[DEVICE TYPE< 介质类型> [PARMS '< 介质参数>']][< database_bakdir_lst_stmt>][CASCADE];
REMOVE [DATABASE | TABLESPACE[] | TABLE ""."" | ARCHIVELOG|ARCHIVE LOG] BACKUPSETS
[]
{[UNTIL TIME '< 截止时间串>'] | [BEFOREn]}
::= DEVICE TYPE< 介质类型> [PARMS '< 介质参数>']
::= DATABASE '' |
WITH BACKUPDIR '< 备份集搜索目录>' {, '< 备份集搜索目录>' } |
DATABASE '' WITH BACKUPDIR '< 备份集搜索目录>' {, '< 备份集搜索目录>' }

BACKUPSET:指定待删除的备份集目录。
DATABASE:指定数据库dm.ini文件路径,若指定,则该数据库的默认备份目录作为备份集搜索目录之一。
DEVICE TYPE:指存储备份集的介质类型,支持DISK和TAPE,默认DISK。DISK表示备份集存储介质磁盘,TAPE表示存储介质为磁带。若未指定,则DISK和TAPE介质上满足条件备份集均会删除。
PARMS:介质类型为TAPE时,第三方介质管理实现所需的参数字符串。
CASCADE:当目标备份集已经被其他备份集引用为基备份集,默认不允许删除,若指定CASCADE,则递归删除所有引用的增量备份。DATABASE|TABLESPACE|TABLE|ARCHIVELOG|ARCHIVE LOG:指定删除备份集的类型,分别为库级、表空间级、表级备份,以及归档级别,其中ARCHVELOG和ARCHIVE LOG等价。若不指定,全部删除。指定TABLESPACE时,若指定目标表空间名,则仅会删除满足条件的指定表空间名称的表空间备份集,否则,删除所有满足条件的表空间级备份集;指定TABLE时,若指定目标表名,则仅会删除满足条件的指定表名的表备份集;否则,删除所有满足条件的表备份集。
UNTIL TIME:删除备份集生成的最大时间,即删除指定时间之前的备份集,若未指定,则删除所有备份集。
BEFOREn:删除距离当前时间前n天产生的备份集;n取值范围0~365,单位:天。
WITH BACKUPDIR:备份集搜索目录,用于搜索指定目录下的所有备份集。

2. 删除备份集
下面举例说明如何使用DMRMAN的REMOVE命令删除备份集,主要内容包括:
1. 删除特定的备份集
2. 批量删除所有备份集
3. 批量删除指定时间之前的备份集

1.删除特定的备份集
使用REMOVE BACKUPSET…命令可删除特定备份集,每次只能删除一个备份集。若删除备份集已经被引用为其他备份集的基备份且未指定CASCADE,则报错。

RMAN> remove backupset '/dm7/backup/db_rac_bak';
remove backupset '/dm7/backup/db_rac_bak';
CMD END.CODE:[0]
remove backupset successfully.
time used: 30.542(ms)

如果备份集在数据库默认备份目录下还可使用以下方式删除备份集:
RMAN> remove backupset 'DB_rac_FULL_20200608_160009_000828';
remove backupset 'DB_rac_FULL_20200608_160009_000828';
CMD END.CODE:[0]
remove backupset successfully.
time used: 57.206(ms)

如果备份集为其他备份集的基备份且备份集都在数据库默认备份目录下还可使用以下方式删除备份集:

RMAN> backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_bak_for_remove_01';
backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_bak_for_remove_01';
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
EP [1] is checking....
EP[0] max_lsn: 58852
EP[0] adjust cur_lsn from [58852] to [58867]
BACKUP DATABASE [rac], execute......
CMD CHECK LSN......
BACKUP DATABASE [rac], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm7/backup/db_rac_bak_for_remove_01] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 3683.477(ms)

–增量备份之前,启动数据库,以便成功生成增量备份

RMAN> backup database '/dm7/data/rac0_config/dm.ini' increment backupset '/dm7/backup/db_rac_bak_for_remove_01_incr';
backup database '/dm7/data/rac0_config/dm.ini' increment backupset '/dm7/backup/db_rac_bak_for_remove_01_incr';
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
EP [1] is checking....
EP[0] max_lsn: 61871
EP[0] adjust cur_lsn from [61871] to [61888]
BACKUP DATABASE [rac], execute......
CMD CHECK LSN......
BACKUP DATABASE [rac], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm7/backup/db_rac_bak_for_remove_01_incr] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 3563.746(ms)


RMAN> remove backupset '/dm7/backup/db_rac_bak_for_remove_01_incr' database '/dm7/data/rac0_config/dm.ini' cascade;
remove backupset '/dm7/backup/db_rac_bak_for_remove_01_incr' database '/dm7/data/rac0_config/dm.ini' cascade;
CMD END.CODE:[0]
remove backupset successfully.
time used: 23.623(ms)

2.批量删除所有备份集
使用REMOVE BACKUPSETS…命令可批量删除备份集。批量删除可选择删除的备份类型,数据库备份、表空间备份、表备份,以及归档备份,不指定则全部删除。下面示例为删除/dm7/backup目录下的所有备份集,可以是联机生成的备份集,也可以脱机DMRMAN工具生成的备份集。

RMAN> backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_bak_for_remove_02';
backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_bak_for_remove_02';
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
EP [1] is checking....
EP[0] max_lsn: 61871
EP[0] adjust cur_lsn from [61871] to [61888]
BACKUP DATABASE [rac], execute......
CMD CHECK LSN......
BACKUP DATABASE [rac], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm7/backup/db_rac_bak_for_remove_02] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 3415.539(ms)

RMAN> remove backupsets with backupdir '/dm7/backup/';
remove backupsets with backupdir '/dm7/backup/';
CMD END.CODE:[-10000],DESC:[Fail in mml(-10000)]
CMD END.CODE:[0]
remove backupset successfully.
time used: 1041.430(ms)

3.批量删除指定时间之前的备份集
REMOVE BACKUPSETS…UNTIL TIME命令用来批量删除指定时间的备份集。通常情况下,用户并不想删除指定目录下所有的备份集,这时可以选择只删除指定时间之前的备份。如何确定删除备份的时间点,需要结合用户的备份计划合理指定。若用户每周做一次完全备份,每天进行增量备份,那么删除的时间可指定为7天前的某个特定时间。假设今天的日期为2020-06-09,要删除7天前/dm7/backup目录下的所有备份在DMRMAN中输入以下命令:

RMAN> remove backupsets with backupdir '/dm7/backup/' until time '2020-06-09 15:20:00';
remove backupsets with backupdir '/dm7/backup/' until time '2020-06-09 15:20:00';
CMD END.CODE:[-10000],DESC:[Fail in mml(-10000)]
CMD END.CODE:[0]
remove backupset successfully.
time used: 1020.600(ms)

DM7使用DMRMAN工具查看备份集

使用DMRMAN工具查看备份集
1. 概述
DMRMAN中使用SHOW命令可以查看备份集的信息,包括:
1. 备份集的数据库信息
2. 备份集的元信息
3. 备份集中文件信息(如备份数据文件DBF和备份片文件)
4. 备份集中表信息(仅对表备份集有效)
若指定具体备份集目录,则会生成相应的备份集链表信息。
语法如下:

SHOW BACKUPSET '< 备份集目录>' [][RECURSIVE] [] []
[];
|SHOW BACKUPSETS [] 
[] [] [];
::= DATABASE '' |
WITH BACKUPDIR '< 备份集搜索目录>'{,'< 备份集搜索目录>'} |
DATABASE '' WITH BACKUPDIR '< 备份集搜索目录>'{, '< 备份集搜索目录>'}
::= DEVICE TYPE DISK|TAPE [PARMS '< 介质参数>']
::= INFO DB[,META][,FILE] [,TABLE]
::= USE DB_MAGIC 
::= TO '< 输出文件路径>' [FORMAT TXT | FORMAT XML]

BACKUPSET:指定显示目标备份集信息,若同时指定RECURSIVE,则显示以该备份集为最新备份集递归显示完整的备份集链表;否则,仅显示指定备份集本身信息。若为完全备份,则仅显示该备份集自身信息。

DATABASE:指定数据库dm.ini文件路径,若指定,则该数据库的默认备份目录作为备份集搜索目录之一。

WITH BACKUPDIR:备份集搜索目录,最大长度为256个字节。若查看完全备份的备份集信息且指定的备份集路径为相对路径可通过设置此参数搜索备份集;若查看的为增量备份集信息,设置该参数除上述功能外还用于搜索基备份集。

: 指定介质类型和介质参数,介质类型支持DISK和TAPE,默认DISK。

:指定显示备份集信息内容,可以组合指定,若未指定,则显示全部。具体说明如下:
1. DB 表示仅显示备份集的数据库信息;
2. META表示仅显示备份集的元信息;
3. FILE表示仅显示备份集中文件信息,如备份数据文件DBF和备份片文件;
4. TABLE 表示显示备份集中表信息,仅对表备份集有效。

:SHOW BACKUPSETS可以指定仅显示指定DB_MAGIC即指定数据库的备份集信息。

:指定备份集信息输出的目标文件路径,若不指定,仅控制台打印。文件格式有两种类型,TXT和XML格式,默认是TXT格式。不支持输出到DMASM文件系统中。指定的文件不能为已经存在的文件,否则报错。

2. 备份信息查看
SHOW命令支持查看单个备份集信息也支持批量查看多个备份集的信息。本节主要举例说明如何执行简单的常用的查看备份集信息操作,包括:
1. 查看指定的备份集信息
2. 批量显示备份集信息
3. 查看指定数据库所有备份集的信息
4. 指定显示部分备份集信息
5. 以xml格式输出备份信息到文件

1.查看指定的备份集信息
SHOW BACKUPSET…命令用于显示特定的备份集信息,每次只能显示一个备份集。当仅需要查看某个特定备份集信息时可以使用此命令。执行
步骤如下:

[dmdba@dmrac1 bin]$ dmrman
dmrman V7.1.6.46-Build(2018.02.08-89107)ENT
RMAN> show backupset '/dm7/backup/db_rac_bak';
show backupset '/dm7/backup/db_rac_bak';




system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK
backupset description:
backupset ID :         1109894076
parent backupset ID:     -1
META file size :       293376
compressed level:      0
encrypt type:          0
parallel num:          4
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51298
END_SEQ:               15673
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         51298
RAC end seq:         15673
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         51235
RAC end seq:         1869
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak
backupset name:        db_rac_bak
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |8         |db_rac_bak.bak                                          |LOG


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time
1         |                                 |3072                |51286               |15668               |8                   |51298               |15673               |0000-00-00 00:00:00 |0000-00-00 00:00:00




system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_2
backupset description:
backupset ID :         66095816
parent backupset ID:     1109894076
META file size :       57856
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_2
backupset name:        db_rac_bak_2
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |85        |db_rac_bak_2.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
3         |4         |MAIN                             |0         |+DMDATA/data/rac/main.dbf        |                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_3
backupset description:
backupset ID :         -1127735780
parent backupset ID:     1109894076
META file size :       57856
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_3
backupset name:        db_rac_bak_3
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |13        |db_rac_bak_3.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
4         |5         |TS_FOR_DBF                       |0         |+DMDATA/data/rac/ts_for_dbf_01.dbf|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_0
backupset description:
backupset ID :         -287144791
parent backupset ID:     1109894076
META file size :       61952
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_0
backupset name:        db_rac_bak_0
backup data file num:  2
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |5005      |db_rac_bak_0.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
1         |0         |SYSTEM                           |0         |+DMDATA/data/rac/system.dbf      |                                 |134217728
5         |5         |TS_FOR_DBF                       |1         |+DMDATA/data/rac/ts_for_dbf_02.dbf|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_1
backupset description:
backupset ID :         -1045365472
parent backupset ID:     1109894076
META file size :       57856
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_1
backupset name:        db_rac_bak_1
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |20997     |db_rac_bak_1.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
2         |1         |ROLL                             |0         |+DMDATA/data/rac/roll.dbf        |                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time




show backupsets successfully.
time used: 14.325(ms)

显示的备份集信息分为三类,依次是元数据信息(META INFO)、文件信息(FILE INFO)和数据库信息(DB INFO)。用户可根据自身需要只显示部分备份集信息,本节下文中会有介绍。

2.批量显示备份集信息
SHOW BACKUPSETS…命令用于批量显示指定搜索目录下的备份集信息。如需要查看的多个备份集不在同一个目录下,可通过多次指定WITH BACKUPDIR参数同时查看所有的备份集。操作如下:

RMAN> backup database '/dm7/data/rac0_config/dm.ini';
backup database '/dm7/data/rac0_config/dm.ini';
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
EP [1] is checking....
EP[0] max_lsn: 58852
EP[0] adjust cur_lsn from [58852] to [58867]
BACKUP DATABASE [rac], execute......
CMD CHECK LSN......
BACKUP DATABASE [rac], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
DBF BACKUP MAIN......
BACKUPSET [+DMDATA/data/rac/bak/DB_rac_FULL_20200608_160009_000828] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 16303.415(ms)
RMAN> backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_full_bak_2020060801';
backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_full_bak_2020060801';
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
EP [1] is checking....
EP[0] max_lsn: 58852
EP[0] adjust cur_lsn from [58852] to [58867]
BACKUP DATABASE [rac], execute......
CMD CHECK LSN......
BACKUP DATABASE [rac], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm7/backup/db_rac_full_bak_2020060801] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 3570.343(ms)


RMAN> show backupsets with backupdir '+DMDATA/data/rac/bak','/dm7/backup';
show backupsets with backupdir '+DMDATA/data/rac/bak' , '/dm7/backup';
CMD END.CODE:[0]








system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_FULL_rac_20200608_160623_000096
backupset description:
backupset ID :         186522112
parent backupset ID:     -1
META file size :       74240
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1591603580
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          offline
backup type:           full
without log:           FALSE
START_LSN:             58853
START_SEQ:             16611
END_LSN:               58867
END_SEQ:               16610
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-06-08 16:06:24
min trx start lsn:     58853
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       58853
RAC begin seq:       16611
RAC end lsn:         58867
RAC end seq:         16610
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       58868
RAC begin seq:       2492
RAC end lsn:         58867
RAC end seq:         2491
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_full_bak_2020060801
backupset name:        db_rac_full_bak_2020060801
backup data file num:  5
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |26103     |db_rac_full_bak_2020060801.bak                          |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
1         |0         |SYSTEM                           |0         |+DMDATA/data/rac/system.dbf      |                                 |134217728
2         |1         |ROLL                             |0         |+DMDATA/data/rac/roll.dbf        |                                 |134217728
3         |4         |MAIN                             |0         |+DMDATA/data/rac/main.dbf        |                                 |134217728
4         |5         |TS_FOR_DBF                       |0         |+DMDATA/data/rac/ts_for_dbf_01.dbf|                                 |134217728
5         |5         |TS_FOR_DBF                       |1         |+DMDATA/data/rac/ts_for_dbf_02.dbf|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_FULL_rac_20200608_160009_000828
backupset description:
backupset ID :         1835676274
parent backupset ID:     -1
META file size :       74240
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1591603207
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          offline
backup type:           full
without log:           FALSE
START_LSN:             58853
START_SEQ:             16611
END_LSN:               58867
END_SEQ:               16610
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-06-08 16:00:17
min trx start lsn:     58853
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       58853
RAC begin seq:       16611
RAC end lsn:         58867
RAC end seq:         16610
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       58868
RAC begin seq:       2492
RAC end lsn:         58867
RAC end seq:         2491
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: +DMDATA/data/rac/bak/DB_rac_FULL_20200608_160009_000828
backupset name:        DB_rac_FULL_20200608_160009_000828
backup data file num:  5
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |26103     |DB_rac_FULL_20200608_160009_000828.bak                  |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
1         |0         |SYSTEM                           |0         |+DMDATA/data/rac/system.dbf      |                                 |134217728
2         |1         |ROLL                             |0         |+DMDATA/data/rac/roll.dbf        |                                 |134217728
3         |4         |MAIN                             |0         |+DMDATA/data/rac/main.dbf        |                                 |134217728
4         |5         |TS_FOR_DBF                       |0         |+DMDATA/data/rac/ts_for_dbf_01.dbf|                                 |134217728
5         |5         |TS_FOR_DBF                       |1         |+DMDATA/data/rac/ts_for_dbf_02.dbf|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK
backupset description:
backupset ID :         1109894076
parent backupset ID:     -1
META file size :       293376
compressed level:      0
encrypt type:          0
parallel num:          4
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51298
END_SEQ:               15673
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         51298
RAC end seq:         15673
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         51235
RAC end seq:         1869
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak
backupset name:        db_rac_bak
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |8         |db_rac_bak.bak                                          |LOG


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time
1         |                                 |3072                |51286               |15668               |8                   |51298               |15673               |0000-00-00 00:00:00 |0000-00-00 00:00:00




system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_2
backupset description:
backupset ID :         66095816
parent backupset ID:     1109894076
META file size :       57856
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_2
backupset name:        db_rac_bak_2
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |85        |db_rac_bak_2.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
3         |4         |MAIN                             |0         |+DMDATA/data/rac/main.dbf        |                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_3
backupset description:
backupset ID :         -1127735780
parent backupset ID:     1109894076
META file size :       57856
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_3
backupset name:        db_rac_bak_3
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |13        |db_rac_bak_3.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
4         |5         |TS_FOR_DBF                       |0         |+DMDATA/data/rac/ts_for_dbf_01.dbf|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_0
backupset description:
backupset ID :         -287144791
parent backupset ID:     1109894076
META file size :       61952
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_0
backupset name:        db_rac_bak_0
backup data file num:  2
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |5005      |db_rac_bak_0.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
1         |0         |SYSTEM                           |0         |+DMDATA/data/rac/system.dbf      |                                 |134217728
5         |5         |TS_FOR_DBF                       |1         |+DMDATA/data/rac/ts_for_dbf_02.dbf|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time






system path:           +DMDATA/data/rac
db magic:              -991931850
permanent magic:       450923536
rac node:              2
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          1
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         rac
backup name:           DB_RAC_BAK_1
backupset description:
backupset ID :         -1045365472
parent backupset ID:     1109894076
META file size :       57856
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1590824489
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          online
backup type:           full
without log:           FALSE
START_LSN:             51236
START_SEQ:             1870
END_LSN:               51235
END_SEQ:               1869
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-05-30 15:41:35
min trx start lsn:     49398
min exec ver:          0x0701060C
pkg size:              0x02000000



RAC EP:            0
RAC status:          OK
RAC begin lsn:       51287
RAC begin seq:       15668
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1

RAC EP:            1
RAC status:          OK
RAC begin lsn:       51236
RAC begin seq:       1870
RAC end lsn:         -1
RAC end seq:         -1
RAC base begin lsn:  -1
RAC base begin seq:  -1
RAC base end lsn:    -1
RAC base end seq:    -1


backupset directory: /dm7/backup/db_rac_bak/db_rac_bak_1
backupset name:        db_rac_bak_1
backup data file num:  1
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |20997     |db_rac_bak_1.bak                                        |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
2         |1         |ROLL                             |0         |+DMDATA/data/rac/roll.dbf        |                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time








show backupsets successfully.
time used: 18.070(ms)

3.查看指定数据库所有备份集的信息
如果指定的备份搜索目录下包含不同数据库的备份集,而我们只想查看某个特定数据库的所有备份集信息,此时可以使用SHOW BACKUPSETS…USE DB_MAGIC命令实现。具体操作如下:

1)备份不同的数据库到不同的目录下。

RMAN> backup database '/dm_home/dmdbms/data/dmks1/dm.ini' backupset '/dm_home/dmdbms/data/bak/db_dmks1_bak_2020060801';
backup database '/dm_home/dmdbms/data/dmks1/dm.ini' backupset '/dm_home/dmdbms/data/bak/db_dmks1_bak_2020060801';
file dm.key not found, use default license!
checking if the database under system path [/dm_home/dmdbms/data/dmks1] is running...[4].
checking if the database under system path [/dm_home/dmdbms/data/dmks1] is running...[3].
checking if the database under system path [/dm_home/dmdbms/data/dmks1] is running...[2].
checking if the database under system path [/dm_home/dmdbms/data/dmks1] is running...[1].
checking if the database under system path [/dm_home/dmdbms/data/dmks1] is running...[0].
checking if the database under system path [/dm_home/dmdbms/data/dmks1] is running, write dmrman info.
EP[0] max_lsn: 61665
BACKUP DATABASE [dmks1], execute......
CMD CHECK LSN......
BACKUP DATABASE [dmks1], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm_home/dmdbms/data/bak/db_dmks1_bak_2020060801] END, CODE [0]......
META GENERATING......
total 7 packages processed...
total 7 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 8043.221(ms)


RMAN> backup database '/dm_home/dmdbms/data/dmks2/dm.ini' backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801';
backup database '/dm_home/dmdbms/data/dmks2/dm.ini' backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801';
checking if the database under system path [/dm_home/dmdbms/data/dmks2] is running...[4].
checking if the database under system path [/dm_home/dmdbms/data/dmks2] is running...[3].
checking if the database under system path [/dm_home/dmdbms/data/dmks2] is running...[2].
checking if the database under system path [/dm_home/dmdbms/data/dmks2] is running...[1].
checking if the database under system path [/dm_home/dmdbms/data/dmks2] is running...[0].
checking if the database under system path [/dm_home/dmdbms/data/dmks2] is running, write dmrman info.
EP[0] max_lsn: 33904
BACKUP DATABASE [dmks2], execute......
CMD CHECK LSN......
BACKUP DATABASE [dmks2], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm_home/dmdbms/backup/db_dmks2_bak_2020060801] END, CODE [0]......
META GENERATING......
total 7 packages processed...
total 7 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 8047.711(ms)

2) 查看指定数据库备份集的信息,获取DB_MAGIC信息。

RMAN> show backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801';
show backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801';




system path:           /dm_home/dmdbms/data/dmks2
db magic:              1486708862
permanent magic:       1155586847
rac node:              1
page check:            0
rlog encrypt:          0
external cipher[id/name]:  0/
external hash[id/name]:  0/
length in char:        0
use new hash:          1
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
unicode_flag/charset:  0
data version:          0x7000A
sys version:           V7.1.6.46-Build(2018.02.08-89107)ENT
enable policy:         0
archive flag:          0
blank_pad_mode:        0
crc_check:             TRUE


backupset sig:         BA
backupset version:     4009
database name:         dmks2
backup name:           DB_FULL_dmks2_20200608_165451_000348
backupset description:
backupset ID :         -479813328
parent backupset ID:     -1
META file size :       66048
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1591606486
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          offline
backup type:           full
without log:           FALSE
START_LSN:             33905
START_SEQ:             14010
END_LSN:               33904
END_SEQ:               14009
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-06-08 16:54:53
min trx start lsn:     33905
min exec ver:          0x0701060C
pkg size:              0x02000000


backupset directory: /dm_home/dmdbms/backup/db_dmks2_bak_2020060801
backupset name:        db_dmks2_bak_2020060801
backup data file num:  3
backup piece num:      1


$file_seq |$size(KB) |$pos_desc                                               |$content_type
0         |5606      |db_dmks2_bak_2020060801.bak                             |DATA


$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len
1         |0         |SYSTEM                           |0         |/dm_home/dmdbms/data/dmks2/SYSTEM.DBF|                                 |22020096
2         |1         |ROLL                             |0         |/dm_home/dmdbms/data/dmks2/ROLL.DBF|                                 |134217728
3         |4         |MAIN                             |0         |/dm_home/dmdbms/data/dmks2/MAIN.DBF|                                 |134217728


$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_time


show backupsets successfully.
time used: 6.251(ms)

通过查看备份集信息可知,数据库/dm_home/dmdbms/data/dmks2的DB_MAGIC值为-1486708862

3) 查看指定目录下数据库/dm_home/dmdbms/data/dmks2的所有备份集信息。

RMAN> show backupsets with backupdir '/dm_home/dmdbms/backup' use db_magic 1486708862;
show backupsets with backupdir '/dm_home/dmdbms/backup' use db_magic 1486708862;
CMD END.CODE:[0]
[602]:no backupsets searched in specified directories

4.指定查看备份集的元数据信息

SHOW BACKUPSET...INFO META命令用于查看备份集的元数据信息。操作步骤如下:
RMAN> show backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801' info meta;
show backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801' info meta;




backupset sig:         BA
backupset version:     4009
database name:         dmks2
backup name:           DB_FULL_dmks2_20200608_165451_000348
backupset description:
backupset ID :         -479813328
parent backupset ID:     -1
META file size :       66048
compressed level:      0
encrypt type:          0
parallel num:          1
backup range:          database
mpp_timestamp:         1591606486
ddl_clone:             FALSE
mpp_flag:              FALSE
backup level:          offline
backup type:           full
without log:           FALSE
START_LSN:             33905
START_SEQ:             14010
END_LSN:               33904
END_SEQ:               14009
base START_LSN:        -1
base END_LSN:          -1
base name:
base backupset:
backup time:           2020-06-08 16:54:53
min trx start lsn:     33905
min exec ver:          0x0701060C
pkg size:              0x02000000


show backupsets successfully.
time used: 5.915(ms)

这里获取的是单个备份集的元数据信息,也可以使用SHOW BACKUPSETS…INFO META命令批量获取元数据信息。同样地,我们可以使用类似的命令指定获取备份集的数据库信息、文件信息和表信息,或这些信息的任意组合。

5.以xml格式输出备份信息到文件
DMRMAN可以将显示的备份集信息输出到文件,目前支持的格式包括TXT和XML,默认为TXT文件格式。使用SHOW BACKUPSETS…TO ‘file_path’ FORMAT XML命令可将备份信息以XML格式显示并输出到文件,如下所示:

RMAN> show backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801' to '/home/dmdba/db_dmks2.txt' format xml;
show backupset '/dm_home/dmdbms/backup/db_dmks2_bak_2020060801' to '/home/dmdba/db_dmks2.txt' format xml;
< ?xml version="1.0" encoding="UTF-8"?>

        
                
                /dm_home/dmdbms/backup/db_dmks2_bak_2020060801
                DISK
                
                        BA
                        4009
                        dmks2
                        DB_FULL_dmks2_20200608_165451_000348
                        
                        -479813328
                        -1
                        66048
                        0
                        0
                        1
                        database
                        1591606486
                        FALSE
                        FALSE
                        offline
                        full
                        FALSE
                        33905
                        14010
                        33904
                        14009
                        -1
                        -1
                        
                        
                        2020-06-08 16:54:53
                        33905
                        0x0701060C
                        0x02000000
                
                
                        /dm_home/dmdbms/backup/db_dmks2_bak_2020060801
                        db_dmks2_bak_2020060801
                        3
                        1
                        
                                0
                                5740032
                                db_dmks2_bak_2020060801.bak
                                DATA
                        
                        
                                1
                                0
                                SYSTEM
                                0
                                /dm_home/dmdbms/data/dmks2/SYSTEM.DBF
                                
                                22020096
                        
                        
                                2
                                1
                                ROLL
                                0
                                /dm_home/dmdbms/data/dmks2/ROLL.DBF
                                
                                134217728
                        
                        
                                3
                                4
                                MAIN
                                0
                                /dm_home/dmdbms/data/dmks2/MAIN.DBF
                                
                                134217728
                        
                
                
                        /dm_home/dmdbms/data/dmks2
                        -1486708862
                        -1155586847
                        1
                        0
                        0
                        0
                        
                        0
                        
                        0
                        1
                        8192
                        16
                        TRUE
                        512
                        0
                        0
                        0x7000A
                        V7.1.6.46-Build(2018.02.08-89107)ENT 
                        FALSE
                        FALSE
                        0
                        TRUE
                
                
        

show backupsets successfully.
time used: 7.438(ms)

DM7使用DMRMAN工具执行加密备份与设置跟踪日志

使用DMRMAN工具执行加密备份与设置跟踪日志
下面介绍使用DMRMAN工具执行加密备份与设置跟踪日志
1.加密备份
DMRMAN同DIsql工具一样可使用加密的方式备份数据库,没有权限的用户无法访问加密的备份集。

DMRMAN备份命令中通过指定IDENTIFIED BY…WITH ENCRYPTION…ENCRYPT WITH…命令执行加密备份。

加密备份过程中参数IDENTIFIED BY必须指定,参数WITH ENCRYPTION和参数ENCRYPT WITH可不指定。加密备份时不指定WITH ENCRYPTION参数,该参数默认为1,不指定ENCRYPT WITH参数,该参数默认值为AES256_CFB。例如,以下两种加密备份命令都是合法的:

RMAN> backup  database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_01' identified by "abcd123456";
backup database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_01' identified by ******;
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 904411
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_jydm_bak_for_encrypt_01] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 8271.759(ms)

RMAN> backup  database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_02' identified by "abcd123456" encrypt with rc4;
backup database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_02' identified by ****** encrypt with ******;
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 904411
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_jydm_bak_for_encrypt_02] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 7166.572(ms)

若指定了加密密码,但加密类型WITH ENCRYPTION参数指定为0,则为非加密备份,如下所示:

RMAN> backup  database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_03' identified by "abcd123456" with encryption 0;
backup database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_03' identified by ****** with encryption *;
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 904411
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_jydm_bak_for_encrypt_03] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 7278.945(ms)

下面以数据库完全备份为例,创建加密密码为“abcd123456”,加密算法为“rc4”的复杂加密类型的数据库加密备份,完整步骤如下:
1) 保证数据库处于关闭状态。
2) 备份数据库。启动DMRMAN工具并输入以下命令。

RMAN> backup  database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_04' identified by "abcd123456" with encryption 2 encrypt with rc4
backup database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_jydm_bak_for_encrypt_04' identified by ****** with encryption * encrypt with ******;
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 904411
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_jydm_bak_for_encrypt_04] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 7280.960(ms)

对于增量备份加密,如果基备份存在加密,则使用的加密算法和加密密码必须与基备份中一致;如果基备份未进行加密处理,则对增量备份使用的加密密码和算法没有特殊要求。

RMAN> backup  database 'E:\dmdbms\data\jydm\dm.ini' increment with backupdir 'E:\dmdbms\backup' backupset 'E:\dmdbms\backup\db_jydm_bak_incr_for_encrypt_01' identified by "abcd123456" with encryption 2 encrypt with rc4;
backup database 'E:\dmdbms\data\jydm\dm.ini' increment with backupdir 'E:\dmdbms\backup' backupset 'E:\dmdbms\backup\db_jydm_bak_incr_for_encrypt_01' identified by ****** with encryption * encrypt with ******;
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 904411
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_jydm_bak_incr_for_encrypt_01] END, CODE [0]......
META GENERATING......
total 0 packages processed...
total 9 packages processed!
CMD END.CODE:[-8088],DESC:[无任何数据更新或者日志产生,无需备份]
[-8088]:无任何数据更新或者日志产生,无需备份
RMAN>

2.设置跟踪日志文件
DMRMAN备份时可选择生成跟踪日志文件,跟踪日志记录了SBT接口的调用过程,用户通过查看日志可跟踪备份还原过程。

与生成跟踪日志文件相关的参数有两个,TRACE FILE和TRACE LEVEL。TRACE FILE用于指定生成的跟踪日志文件路径。与DIsql工具不同的是,DMRMAN不可在备份时指定参数生成跟踪文件,只能使用CONFIGURE命令进行事先配置。

使用CONFIGURE DEFAULT…TRACE FILE…TRACE LEVEL命令启用TRACE功能并设TRACE文件路径,以下命令生成TRACE文件到E:\dmdbms\trace目录:

RMAN> configure
configure
THE DMRMAN DEFAULT SETTING:

DEFAULT DEVICE:
        MEDIA : DISK
DEFAULT TRACE :
        FILE  : ..\dm_SBTTRACE_202005.log
        LEVEL : 1
DEFAULT BACKUP DIRECTORY:
        TOTAL COUNT  :1

        E:\dmdbms\backup
DEFAULT ARCHIVE DIRECTORY:
        TOTAL COUNT  :1

                        E:\dmdbms\data\arch
time used: 37.758(ms)
RMAN> configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 2;
configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 2;
configure default trace successfully!
time used: 3.387(ms)
RMAN> configure
configure
THE DMRMAN DEFAULT SETTING:

DEFAULT DEVICE:
        MEDIA : DISK
DEFAULT TRACE :
        FILE  : E:\dmdbms\trace\db_jydm_trace.log
        LEVEL : 2
DEFAULT BACKUP DIRECTORY:
        TOTAL COUNT  :1

        E:\dmdbms\backup
DEFAULT ARCHIVE DIRECTORY:
        TOTAL COUNT  :1

                        E:\dmdbms\data\arch
time used: 40.347(ms)

指定参数TRACE FILE但TRACE LEVEL值设置为1即不启用TRACE功能,会生成TRACE文件,但不会写入TRACE信息。如下所示:

RMAN> configure default trace clear;
configure default trace clear;
configure default trace clear successfully!
time used: 2.183(ms)
RMAN> configure
configure
THE DMRMAN DEFAULT SETTING:

DEFAULT DEVICE:
        MEDIA : DISK
DEFAULT TRACE :
        FILE  :
        LEVEL : 1
DEFAULT BACKUP DIRECTORY:
        TOTAL COUNT  :1

        E:\dmdbms\backup
DEFAULT ARCHIVE DIRECTORY:
        TOTAL COUNT  :1

                        E:\dmdbms\data\arch
time used: 46.771(ms)

RMAN> configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 1;
configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 1;
configure default trace successfully!
time used: 4.799(ms)

TRACE LEVEL值设置为2即启用TRACE功能,但若TRACE FILE没有指定,系统默认在执行码路径的log目录下生成DM_SBTTRACE_年月.log文件。
如下所示:

RMAN> configure default trace level 2;
configure default trace level 2;
configure default trace successfully!
time used: 3.124(ms)

若TRACE FILE使用相对路径,日志文件则生成在执行码同级目录下。
为数据库脱机备份设置跟踪日志文件的操作步骤如下:
1) 保证数据库处于关闭状态。
2) 使用CONFIGURE命令配置生成跟踪日志文件。

RMAN> configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 2;
configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 2;
configure default trace successfully!
time used: 2.705(ms)

查看E:\dmdbms\trace\db_jydm_trace.log文件即可跟踪本次备份的SBT接口调用过程。
如果指定的TRACE文件已存在,服务器不会覆盖已存在的文件而是在已有文件基础上继续记录日志。

RMAN> configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 1;
configure default trace file 'E:\dmdbms\trace\db_jydm_trace.log' trace level 1;
[-8086]:无效的TRACE文件[E:\dmdbms\trace\db_jydm_trace.log]

DM7使用DMRMAN执行归档备份

使用脱机工具DMRMAN执行归档备份
1. 概述
在DMRMAN工具中使用BACKUP命令你可以备份数据库的归档。关闭服务器在DMRMAN中输入以下命令即可备份归档:

RMAN> backup archive log database 'E:\dmdbms\data\jydm\dm.ini';
backup archive log database 'E:\dmdbms\data\jydm\dm.ini';
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 901685
BACKUP ARCHIVE LOG ALL, execute......
CMD CHECK LSN......
BACKUP ARCHIVE LOG ALL, collect dbf......
CMD CHECK ......
ARCH BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
ARCH BACKUP MAIN......
BACKUPSET [E:\dmdbms\data\jydm\bak\ARCH_LOG_20200531_193129_000908] END, CODE [0]......
META GENERATING......
total 5 packages processed...
total 5 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 7252.182(ms)

命令执行完后会在默认的备份路径下生成备份集目录,默认的备份路径为dm.ini中BAK_PATH的配置值,若未配置,则使用SYSTEM_PATH下的bak目录。这是最简单的脱机归档备份语句,如果要设置其他备份选项请参考下文的语法及使用说明。

语法如下:

BACKUP
[ALL | [FROM LSN ]|[UNTIL LSN ] | [LSN BETWEEN < lsn值> AND < lsn值>] | [FROM TIME '时间串'] |
[UNTIL TIME '时间串'] | [TIME BETWEEN '时间串' AND '时间串']] [][DELETE INPUT]
DATABASE ''
[TO < 备份名>] [BACKUPSET '< 备份集目录>'] [DEVICE TYPE < 介质类型>[PARMS '< 介质参数>']
[BACKUPINFO '< 备份描述>'] [MAXPIECESIZE < 备份片限制大小>]
[IDENTIFIED BY < 加密密码>[WITH ENCRYPTION][ENCRYPT WITH < 加密算法>]]
[COMPRESSED [LEVEL < 压缩级别>]][TASK THREAD < 线程数>][PARALLEL [< 并行数>]];
::=NOT BACKED UP
| NOT BACKED UP numTIMES
| NOT BACKED UP SINCE TIME 'datetime_string'

ALL:备份所有的归档;
FROM LSN ,UNTIL LSN:备份的起始和截止lsn。请参考3.2.2.4归档备份
FROM TIME:指定备份的开始时间点。例如,’2015-12-10’。
UNTIL TIME:指定备份的截止时间点。
BETWEEN …AND …:指定备份的区间,仅仅指备份区间内的归档文件。
:搜索过滤。搜索过滤仅限于根据备份指定条件能找到的所有归档备份集。1) num TIMES,指若归档文件已经备份了num次,则不再备份;否则备份。如num=3,则认为已经备份了3次的归档文件就不再备份。若num=0,则认为所有都不需要备份。2)SINCE TIME ‘datetime_String’,指定时间开始没有备份的归档文件进行备份。3)若以上两种均未指定,则备份所有未备份过的归档日志文件。
DELETE INPUT:用于指定备份完,是否删除归档操作。
DATABASE:必选参数。指定备份目标库的INI文件路径。
TO: 指定生成备份名称。若未指定,系统随机生成,默认备份名格式为:ARCH_备份时间。
BACKUPSET: 指定当前备份集生成目录。若指定为相对路径,则在默认备份路径中生成备份集。
DEVICE TYPE:指存储备份集的介质类型,支持DISK和TAPE,默认DISK。DISK表示存储备份集到磁盘,TAPE表示存储到磁带。
PARMS:只对介质类型为TAPE时有效。
BACKUPINFO:备份的描述信息。最大不超过256个字节。
MAXPIECESIZE:最大备份片文件大小上限,以M为单位,最小128M,32位系统最大2G,64位系统最大128G。
IDENTIFIED BY:指定备份时的加密密码。密码应用双引号括起来,这样避免一些特殊字符通不过语法检测。密码的设置规则遵行ini参数pwd_policy指定的口令策略。
WITH ENCRYPTION:指定加密类型,0表示不加密,不对备份文件进行加密处理;1表示简单加密,对备份文件设置口令,但文件内容仍以明文存;2表示完全数据加密,对备份文件进行完全的加密,备份文件以密文方式存储。
ENCRYPT WITH:加密算法。缺省情况下,算法为AES256_CFB。具体可以使用的加密算法参考联机数据库备份章节的参数说明。
COMPRESSED:取值范围0~9。0表示不压缩,1表示1级压缩,9表示9级压缩。压缩级别越高,压缩越慢,但压缩比越高。若未指定,但指定COMPRESSED,则默认1;否则,默认0。
TASK THREAD:备份过程中数据处理过程线程的个数,取值范围0~64,默认为4。若指定为0,则调整为1;若指定超过当前系统主机核数,则调整为主机核数。线程数(TASK THREAD)*并行数(PARALLEL)不得超过512。
PARALLEL:指定并行备份的并行数,取值范围0~128。若不指定,则默认为4,指定0或者1均认为为非并行备份。若未指定关键PARALLEL,则认为非并行备份。并行备份不支持介质为TAPE的备份。线程数(TASK THREAD)*并行数(PARALLEL)不得超过512。

2. 备份归档
本节主要描述使用DMRMAN如何执行基本的脱机归档备份及实施一些备份策略,包括:
1. 设置备份选项
2. 创建归档备份
3. 创建设置条件的归档备份

1.设置备份选项
备份命令如果仅指定了必选参数如“BACKUP ARCHIVE LOG DATABASE ‘/opt/dmdbms/data/DAMENG/dm.ini’”,那么DMRMAN会根据配置的环境及内置的参数默认值自动指定备份介质类型、备份路径、备份片大小等参数。用户备份时也可以指定这些参数来覆盖默认值,常见的备份选项有设置备份集路径、指定备份名、限制备份片大小、添加描述信息、并行备份等。DMRMAN脱机备份归档的语法与使用DIsql联机备份类似,关于备份选项的详细介绍及使用参见3.2.2.3.2 设置备份选项。

2.创建归档备份
执行归档备份要求数据库处于脱机状态。与联机备份数据库一样,脱机归档备份需要配置归档。一个完整的创建脱机数据库备份的示例如下:
1) 启动DMRMAN命令行工具。
2) 保证数据库处于脱机状态。
3) DMRMAN中输入以下命令:

RMAN> backup archive log all database 'E:\dmdbms\data\jydm\dm.ini' backupset 'E:\dmdbms\backup\arch_all_bak_01';
backup archive log all database 'E:\dmdbms\data\jydm\dm.ini' backupset 'E:\dmdbms\backup\arch_all_bak_01';
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 901685
BACKUP ARCHIVE LOG ALL, execute......
CMD CHECK LSN......
BACKUP ARCHIVE LOG ALL, collect dbf......
CMD CHECK ......
ARCH BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
ARCH BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\arch_all_bak_01] END, CODE [0]......
META GENERATING......
total 5 packages processed...
total 5 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 8221.506(ms)

命令中的ALL参数表示执行的备份为备份所有的归档,也可以不指定该参数,DMRMAN默认执行的备份类型为ALL类型归档备份。

3.创建设置条件的归档备份
设置条件的归档备份指通过设置LSN或者时间点,控制归档需要备份归档的范围。脱机设置条件归档备份。增量备份示例如下:

D:\>net start DmServicejydm
DmServicejydm 服务正在启动 ....
DmServicejydm 服务已经启动成功。


D:\>disql sysdba/xxzx7817600

服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间: 10.068(毫秒)
disql V7.1.6.48-Build(2018.03.01-89507)ENT
Connected to: DM 7.1.6.48
SQL> select * from v$arch_file;

行号       DB_MAGIC    STATUS   LEN                  FREE                 ARCH_LSN             CLSN                 ARCH_SEQ             NEXT_SEQ             CREATE_TIME                 CLOSE_TIME                  PATH
---------- ----------- -------- -------------------- -------------------- -------------------- -------------------- -------------------- -------------------- --------------------------- --------------------------- ----------------------------------------------------------
1          -430050549  INACTIVE 225792               225792               892254               894139               161798               162230               2020-05-31 10:17:40.810000  2020-05-31 11:52:15.732000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531101740800_0.log
2          -430050549  INACTIVE 282112               282112               894139               896221               162231               162773               2020-05-31 11:52:15.732000  2020-05-31 18:10:29.344000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531115215733_0.log
3          -430050549  INACTIVE 198656               198656               896222               898933               162774               163153               2020-05-31 18:10:29.344000  2020-05-31 18:11:41.803000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531181130589_0.log
4          -430050549  INACTIVE 202752               202752               898934               901685               163154               163541               2020-05-31 18:11:41.803000  2020-05-31 19:22:33.194000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531192047977_0.log
5          -430050549  ACTIVE   1073741824           4608                 901686               901686               163542               163542               2020-05-31 19:22:33.194000  2020-05-31 19:41:37.396000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531194137390_0.log

已用时间: 7.243(毫秒). 执行号:3.
SQL> begin
2   for i in 11 .. 20 loop
3   insert into t2 values(i);
4   end loop;
5   commit;
6   end;
7   /
DMSQL 过程已成功完成
已用时间: 3.688(毫秒). 执行号:4.
SQL> alter system switch logfile;
操作已执行
已用时间: 15.692(毫秒). 执行号:0.
SQL> select * from v$arch_file;

行号       DB_MAGIC    STATUS   LEN                  FREE                 ARCH_LSN             CLSN                 ARCH_SEQ             NEXT_SEQ             CREATE_TIME                 CLOSE_TIME                  PATH
---------- ----------- -------- -------------------- -------------------- -------------------- -------------------- -------------------- -------------------- --------------------------- --------------------------- ----------------------------------------------------------
1          -430050549  ACTIVE   1073741824           4096                 0                    0                    0                    0                    2020-05-31 19:43:28.792000  2020-05-31 19:43:28.797000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531194328794_0.log
2          -430050549  INACTIVE 225792               225792               892254               894139               161798               162230               2020-05-31 10:17:40.810000  2020-05-31 11:52:15.732000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531101740800_0.log
3          -430050549  INACTIVE 282112               282112               894139               896221               162231               162773               2020-05-31 11:52:15.732000  2020-05-31 18:10:29.344000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531115215733_0.log
4          -430050549  INACTIVE 198656               198656               896222               898933               162774               163153               2020-05-31 18:10:29.344000  2020-05-31 18:11:41.803000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531181130589_0.log
5          -430050549  INACTIVE 202752               202752               898934               901685               163154               163541               2020-05-31 18:11:41.803000  2020-05-31 19:22:33.194000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531192047977_0.log
6          -430050549  INACTIVE 143872               143872               901686               903130               163542               163814               2020-05-31 19:22:33.194000  2020-05-31 19:43:28.792000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531194137390_0.log

6 rows got

已用时间: 8.257(毫秒). 执行号:5.
SQL> checkpoint(100);
DMSQL 过程已成功完成
已用时间: 19.634(毫秒). 执行号:6.
SQL> alter database archivelog current;
操作已执行
已用时间: 15.156(毫秒). 执行号:0.
SQL> select * from v$arch_file;

行号       DB_MAGIC    STATUS   LEN                  FREE                 ARCH_LSN             CLSN                 ARCH_SEQ             NEXT_SEQ             CREATE_TIME                 CLOSE_TIME                  PATH
---------- ----------- -------- -------------------- -------------------- -------------------- -------------------- -------------------- -------------------- --------------------------- --------------------------- ----------------------------------------------------------
1          -430050549  ACTIVE   1073741824           4096                 0                    0                    0                    0                    2020-05-31 19:44:15.929000  2020-05-31 19:44:15.934000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531194415931_0.log
2          -430050549  INACTIVE 225792               225792               892254               894139               161798               162230               2020-05-31 10:17:40.810000  2020-05-31 11:52:15.732000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531101740800_0.log
3          -430050549  INACTIVE 282112               282112               894139               896221               162231               162773               2020-05-31 11:52:15.732000  2020-05-31 18:10:29.344000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531115215733_0.log
4          -430050549  INACTIVE 198656               198656               896222               898933               162774               163153               2020-05-31 18:10:29.344000  2020-05-31 18:11:41.803000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531181130589_0.log
5          -430050549  INACTIVE 202752               202752               898934               901685               163154               163541               2020-05-31 18:11:41.803000  2020-05-31 19:22:33.194000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531192047977_0.log
6          -430050549  INACTIVE 143872               143872               901686               903130               163542               163814               2020-05-31 19:22:33.194000  2020-05-31 19:43:28.792000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531194137390_0.log
7          -430050549  INACTIVE 9728                 9728                 903130               903130               163815               163825               2020-05-31 19:43:28.792000  2020-05-31 19:44:15.929000  E:\dmdbms\data\arch\ARCHIVE_LOCAL1_20200531194328794_0.log

7 rows got

1) 启动DMRMAN命令行工具。
2) 保证数据库处于脱机状态。

D:\>net stop DmServicejydm
DmServicejydm 服务正在停止...
DmServicejydm 服务已成功停止。

3) DMRMAN中输入以下命令:

RMAN> backup archive log lsn between 901686 and 903130 database 'E:\dmdbms\data\jydm\dm.ini' backupset 'E:\dmdbms\backup\arch_lsn_bak_01';
backup archive log lsn between 901686 and 903130 database 'E:\dmdbms\data\jydm\dm.ini' backupset 'E:\dmdbms\backup\arch_lsn_bak_01';
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 904411
BACKUP ARCHIVE LOG FROM LSN 901686 TO LSN 903130, execute......
CMD CHECK LSN......
BACKUP ARCHIVE LOG FROM LSN 901686 TO LSN 903130, collect dbf......
CMD CHECK ......
ARCH BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
ARCH BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\arch_lsn_bak_01] END, CODE [0]......
META GENERATING......
total 3 packages processed...
total 3 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 7313.615(ms)

命令中的LSN BETEEWN start AND end参数表示执行的备份为执行备份的区间,或者设置FROM LSN(TIME)以及UNTIL LSN(TIME)。

DM7使用脱机工具DMRMAN执行数据库备份

脱机工具DMRMAN执行数据库备份
1. 概述
在DMRMAN工具中使用BACKUP命令你可以备份整个数据库。使用DMRMAN备份数据库不需要设置归档,关闭服务器在DMRMAN中输入以下命令即可备份数据库:

C:\Users\Administrator>net stop DmServicejydm
DmServicejydm 服务正在停止..
DmServicejydm 服务已成功停止。

RMAN> backup database 'E:\dmdbms\data\jydm\dm.ini';
backup database 'E:\dmdbms\data\jydm\dm.ini';
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 898933
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\data\jydm\bak\DB_jydm_FULL_20200531_181250_000528] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 8302.098(ms)

命令执行完后会在默认的备份路径下生成备份集目录,默认的备份路径为dm.ini中BAK_PATH的配置值,若未配置,则为SYSTEM_PATH下的bak目录。这是最简单的脱机数据库备份语句,如果要设置其他备份选项请参考下文的语法及使用说明。语法如下:

BACKUP DATABASE '<INI文件路径>' [[[FULL][DDL_CLONE]] |INCREMENT [CUMULATIVE][WITH BACKUPDIR '<基备份搜索目录>'{,'<基备份搜索目录>'}]|[BASE ON BACKUPSET '<基备份集目录>']]
[TO <备份名>] [BACKUPSET '<备份集目录>'][DEVICE TYPE <介质类型>[PARMS '<介质参数>']
[BACKUPINFO '<备份描述>'] [MAXPIECESIZE <备份片限制大小>]
[IDENTIFIED BY <加密密码>[WITH ENCRYPTION][ENCRYPT WITH <加密算法>]]
[COMPRESSED [LEVEL <压缩级别>]][WITHOUT LOG]
[TASK THREAD <线程数>][PARALLEL [<并行数>]];

DATABASE:必选参数。指定还原目标库的INI文件路径。

FULL:备份类型。FULL表示完全备份,可不指定,DMRMAN会默认为完全备份。

DDL_CLONE:数据库克隆。该参数只能用于完全备份中,表示仅拷贝所有的元数据不拷贝数据。如对于数据库中的表来说,只备份表的定义不备份表中数据。

INCREMENT:备份类型。INCREMENT表示增量备份,若要执行增量备份必须指定该参数。

WITH BACKUPDIR:用于增量备份中,指定基备份的搜索目录,最大长度为256个字节。若不指定,服务器自动在默认备份目录下搜索基备份。如果基备份不在默认的备份目录下,增量备份必须指定该参数。

CUMULATIVE:用于增量备份中,指明为累积增量备份类型,若不指定则缺省为差异增量备份类型。

BASE ON BACKUPSET:用于增量备份中,为增量备份指定基备份集目录。,如果没有指定基备份集,则会自动搜索一个最近可用的备份集作为基备份集

TO:指定生成备份名称。若未指定,系统随机生成,默认备份名格式为:DB_备份类型_数据库名_备份时间。

BACKUPSET:指定当前备份集生成目录。若指定为相对路径,则在默认备份路径中生成备份集。

DEVICE TYPE:指存储备份集的介质类型,支持DISK和TAPE,默认DISK。DISK表示存储备份集到磁盘,TAPE表示存储到磁带。

PARMS:只对介质类型为TAPE时有效。

BACKUPINFO:备份的描述信息。最大不超过256个字节。

MAXPIECESIZE:最大备份片文件大小上限,以M为单位,最小128M,32位系统最大2G,64位系统最大128G。

IDENTIFIED BY:指定备份时的加密密码。密码应用双引号括起来,这样避免一些特殊字符通不过语法检测。密码的设置规则遵行ini参数pwd_policy指定的口令策略。

WITH ENCRYPTION:指定加密类型,0表示不加密,不对备份文件进行加密处理;1表示简单加密,对备份文件设置口令,但文件内容仍以明文存;2表示完全数据加密,对备份文件进行完全的加密,备份文件以密文方式存储。

ENCRYPT WITH:加密算法。缺省情况下,算法为AES256_CFB。具体可以使用的加密算法参考联机数据库备份章节的参数说明。

COMPRESSED:取值范围0~9。0表示不压缩,1表示1级压缩,9表示9级压缩。压缩级别越高,压缩越慢,但压缩比越高。若未指定,但指定COMPRESSED,则默认1;否则,默认0。

WITHOUT LOG:脱机数据库备份是否备份日志。如果使用,则表示不备份,否则表示备份。如果使用了WITHOUT LOG参数,则使用DMRMAN工具还原时,必须指定WITH ARCHIVEDIR参数。

TASK THREAD:备份过程中数据处理过程线程的个数,取值范围0~64,默认为4。若指定为0,则调整为1;若指定大于当前系统主机核数,则调整为当前主机核数。线程数(TASK THREAD)*并行数(PARALLEL)不得超过512。

PARALLEL:指定并行备份的并行数,取值范围0~128。若不指定,则默认为4,指定0或者1均认为为非并行备份。若未指定关键PARALLEL,则认为非并行备份。并行备份不支持介质为TAPE的备份。线程数(TASK THREAD)*并行数(PARALLEL)不得超过512。

使用说明:
1. 备份成功后会在<备份集目录>或者备份默认目录下生成备份集。备份集中包括一个备份元数据文件,后缀.meta,一个或多个备份片文件,后缀.bak。

2. 对于并行备份的备份集,备份集中还包括其他子备份集目录,但每个子备份集目录中也都包含一个meta文件,0个或者多个备份片文件。

3. DDL_CLONE库备份集不能作为增量备份的基备份,仅能用于库级还原。

4.脱机备份的数据库可以正常退出库,也可以是故障退出的数据库。若是故障退出的数据库,则备份前,需先进行归档修复。

5. 在执行脱机数据库备份过程中,如果报错归档不完整,则需要检查库是不是异常退出。如果库是异常退出,则需要先进行归档修复。

2. 备份数据库
本节主要描述使用DMRMAN如何执行基本的脱机数据库备份及实施一些备份策略,包括:
1. 设置备份选项
2. 创建完全备份
3. 创建增量备份

1.设置备份选项
备份命令如果仅指定了必选参数如“BACKUP DATABASE ‘/opt/dmdbms/data/DAMENG/dm.ini’”,那么DMRMAN会根据配置的环境及内置的参数默认值自动指定备份介质类型、备份路径、备份片大小等参数。用户备份时也可以指定这些参数来覆盖默认值,常见的备份选项有设置备份集路径、指定备份名、限制备份片大小、添加描述信息、并行备份等。DMRMAN脱机备份数据库的语法与使用DIsql联机备份类似。

2.创建完全备份
执行数据库备份要求数据库处于脱机状态。与联机备份数据库不同的是,脱机备份不需要配置归档。一个完整的创建脱机数据库备份的示例如下:
1) 启动DMRMAN命令行工具。
2) 保证数据库处于脱机状态。
3) DMRMAN中输入以下命令:

RMAN> backup database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_full_bak_01';
backup database 'E:\dmdbms\data\jydm\dm.ini' full backupset 'E:\dmdbms\backup\db_full_bak_01';
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 898933
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_full_bak_01] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 7256.870(ms)

RAC使用dmrman执行备份

[dmdba@dmrac1 bin]$ dmrman
dmrman V7.1.6.46-Build(2018.02.08-89107)ENT
RMAN> backup database '/dm7/data/rac0_config/dm.ini' backupset '/dm7/backup/bak/db_rac_full_bak_2020060801';
backup database '/dm7/data/rac0_config/dm.ini' backupset '/dm7/backup/bak/db_rac_full_bak_2020060801';
file dm.key not found, use default license!
Read ini warning, default backup path [/dm7data/bak] does not exist.
[-105]:Invalid control file

报错是因为对于rac环境来说在启动dmrman时需要指定dcr_ini参数

[dmdba@dmrac1 bin]$ dmrman dcr_ini=/dm7/data/dmdcr.ini
dmrman V7.1.6.46-Build(2018.02.08-89107)ENT
RMAN> backup database '/dm7/data/rac0_config/dm.ini';
backup database '/dm7/data/rac0_config/dm.ini';
file dm.key not found, use default license!
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
[-12000]:The specified instance has been started

报错是因为指定的数据库实例已经启动了,dmrman是用于脱机备份,所以需要停止数据库

RMAN> backup database '/dm7/data/rac0_config/dm.ini';
backup database '/dm7/data/rac0_config/dm.ini';
checking if the RAC database under system path [+DMDATA/data/rac] is running....
EP [0] is checking....
EP [1] is checking....
EP[0] max_lsn: 58852
EP[0] adjust cur_lsn from [58852] to [58867]
BACKUP DATABASE [rac], execute......
CMD CHECK LSN......
BACKUP DATABASE [rac], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
DBF BACKUP MAIN......
BACKUPSET [+DMDATA/data/rac/bak/DB_rac_FULL_20200608_160009_000828] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 16303.415(ms)

命令中的FULL参数表示执行的备份为完全备份,也可以不指定该参数,DMRMAN默认执行的备份类型为完全备份。

3.创建增量备份
增量备份指基于指定的库的某个备份(完全备份或者增量备份),备份自该备份以来所有发生修改了的数据页。脱机增量备份要求两次备份之间数据库必须有操作,否则备份会报错。增量备份示例如下:
首先启动数据库执行一些操作

C:\Users\Administrator>net start DmServicejydm
DmServicejydm 服务正在启动 ....
DmServicejydm 服务已经启动成功。

SQL> create table t2(id int);
操作已执行
已用时间: 8.250(毫秒). 执行号:5.
SQL> begin
2   for i in 1 .. 10 loop
3   insert into t2 values(i);
4   end loop;
5   commit;
6   end;
7   /
DMSQL 过程已成功完成
已用时间: 2.845(毫秒). 执行号:6.
SQL> exit

1) 启动DMRMAN命令行工具。
2) 保证数据库处于脱机状态。

C:\Users\Administrator>net stop DmServicejydm
DmServicejydm 服务正在停止..
DmServicejydm 服务已成功停止。

3) DMRMAN中输入以下命令:

RMAN> backup database 'E:\dmdbms\data\jydm\dm.ini' increment with backupdir 'E:\dmdbms\backup' backupset 'E:\dmdbms\backup\db_full_bak_02';
backup database 'E:\dmdbms\data\jydm\dm.ini' increment with backupdir 'E:\dmdbms\backup' backupset 'E:\dmdbms\backup\db_full_bak_02';
checking if the database under system path [E:\dmdbms\data\jydm] is running...[4].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[3].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[2].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[1].
checking if the database under system path [E:\dmdbms\data\jydm] is running...[0].
checking if the database under system path [E:\dmdbms\data\jydm] is running, write dmrman info.
EP[0] max_lsn: 901685
BACKUP DATABASE [jydm], execute......
CMD CHECK LSN......
BACKUP DATABASE [jydm], collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 1 packages processed...
total 2 packages processed...
total 3 packages processed...
total 4 packages processed...
total 5 packages processed...
total 6 packages processed...
total 7 packages processed...
total 8 packages processed...
DBF BACKUP MAIN......
BACKUPSET [E:\dmdbms\backup\db_full_bak_02] END, CODE [0]......
META GENERATING......
total 9 packages processed...
total 9 packages processed!
CMD END.CODE:[0]
backup successfully!
time used: 8219.138(ms)

命令中的INCREMENT参数表示执行的备份为增量备份,增量备份该参数不可省略。如果增量备份的基备份不在默认备份目录,必须指定WITH BACKUPDIR参数用于搜索基备份集,或者使用CONFIGURE…BACKUPDIR命令配置默认的基备份集搜索目录

Proudly powered by WordPress | Indrajeet by Sus Hill.