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)
Proudly powered by WordPress | Indrajeet by Sus Hill.