精华内容
下载资源
问答
  • Oracle RMAN(Recovery Manager) – 备份集备份与镜像复制备份Filed under Oracle Backup and Recovery(备份恢复), oracle, RMAN, 备份, 备份集, 恢复, 镜像复制 backup命令能够产生两种备份:备份集和镜像复制。...

    58a74acb6e52d925ef9b4757a6017a84.png

    Oracle RMAN(Recovery Manager) – 备份集备份与镜像复制备份

    Filed under Oracle Backup and Recovery(备份恢复), oracle, RMAN, 备份, 备份集, 恢复, 镜像复制

    backup命令能够产生两种备份:备份集和镜像复制。

    RMAN> show device type;

    RMAN configuration parameters for database with db_unique_name MAA are:

    CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

    – 表示默认为备份集备份

    backup其实更正确的命令为backup as backupset。执行该命令的时候数据库必须在MOUNT或是OPEN状态,如果是OPEN状态,那么数据库必须运行于归档模式。

    [oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0.1/dbhome_1

    [oracle@localhost ~]$ export ORACLE_SID=luocs10g

    [oracle@localhost ~]$ /u01/app/oracle/product/10.2.0.1/dbhome_1/bin/sqlplus "/as sysdba"

    SQL> archvie log list

    SP2-0734: unknown command beginning "archvie lo..." - rest of line ignored.

    SQL> archive log list

    Database log mode No Archive Mode

    Automatic archival Disabled

    Archive destination /u01/app/oracle/product/10.2.0.1/dbhome_1/dbs/arch

    Oldest online log sequence 471

    Current log sequence 473

    [oracle@localhost ~]$ /u01/app/oracle/product/10.2.0.1/dbhome_1/bin/rman target /

    Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 5 18:30:49 2012

    Copyright (c) 1982, 2005, Oracle. All rights reserved.

    connected to target database: LUOCS10G (DBID=1391338094)

    RMAN> backup as backupset datafile 5;

    Starting backup at 05-NOV-2012 18:31:34

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: sid=118 devtype=DISK

    channel ORA_DISK_1: starting full datafile backupset

    channel ORA_DISK_1: specifying datafile(s) in backupset

    RMAN-00571: ===========================================================

    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

    RMAN-00571: ===========================================================

    RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/05/2012 18:31:35

    ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode

    创建备份集

    术语解释

    输入文件:被RMAN备份的文件,都有控制文件、归档日志、数据文件、参数文件4类;

    备份集:输入文件的备份,物理上由备份片(Backup Piece)组成;

    备份片:一种由RMAN管理的文件,一般以备份文件相称。一个备份片可以包含多个输入文件,一个输入文件也可以分散在多个备份片中。从备份管理的角度出发,可以认为备份集就是备份片的集合。备份片的命名方式分为传统和OMF两种:传统方式格式由format子句指定;OMF则采用自动格式,只要使用闪回恢复区或"to destination"子句即是利用OMF。

    传统方式:

    %a 数据库活动id

    %c 备份片拷贝数

    %d 数据库名

    %D 天(DD)

    %e 归档序列号

    %F c-iiiiiiiiii-YYYYMMDD-QQ ,iiiiiiiiii是数据库id号,QQ是1-256的序列

    %I dbid

    %p 备份集中的备份片号

    %s 备份集编号

    %t 时间戳

    %T YYYYMMDD,年月日

    %u 八字符表示的备份集创建时间

    %U %u_%p_%c

    OMF方式:

    RMAN> backup current controlfile;

    Starting backup at 06-NOV-2012 02:36:50

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=58 device type=DISK

    channel ORA_DISK_1: starting full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    including current control file in backup set

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 02:36:51

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 02:36:52

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnnf_TAG20121106T023650_89j1t3ml_.bkp tag=TAG20121106T023650 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 02:36:52

    备份片名称:o1_mf_ncnnf_TAG20121106T023650_89j1t3ml_.bkp

    从这里我们需要关注的是从7~11个字符,它表示在备份片中的输入文件是何种类型,分别有:

    a – 归档日志

    c – 控制文件

    s – 参数文件

    d – 数据文件

    f – 除归档日志以外的任何文件

    n – 出现在哪个位置,就表示否定含义,代表没有此类输入文件

    比如上面输出的o1_mf_ncnnf_TAG20121106T023650_89j1t3ml_.bkp,其中ncnnf抛去3个n和f,就是控制文件

    RMAN> backup datafile 6;

    Starting backup at 06-NOV-2012 02:45:31

    using channel ORA_DISK_1

    channel ORA_DISK_1: starting full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 02:45:31

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 02:45:32

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T024531_89j2bcop_.bkp tag=TAG20121106T024531 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 02:45:32

    RMAN> backup spfile;

    Starting backup at 06-NOV-2012 02:46:32

    using channel ORA_DISK_1

    channel ORA_DISK_1: starting full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    including current SPFILE in backup set

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 02:46:32

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 02:46:33

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsnf_TAG20121106T024632_89j2d8p7_.bkp tag=TAG20121106T024632 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 02:46:33

    o1_mf_nnndf_TAG20121106T024531_89j2bcop_.bkp和o1_mf_nnsnf_TAG20121106T024632_89j2d8p7_.bkp,从中前面的表示数据文件,后面的为参数文件。

    backup命令所产生的备份集的数量由以下几个因素决定。

    1)输入文件的数量

    2)并行度

    3)输入文件的种类

    4)小括号的使用

    5)"plus archivelog"子句

    输入文件的数量

    一个备份集至少包含一个输入文件,输入文件不可以跨越多个备份集,所以备份集的数量不会超过输入文件的数量。

    默认情况下一个备份集最多容纳64个输入文件,backup命令的filesperset子句可以修改这一设置。

    看示例,我的L表空间有三个数据文件

    SQL> col FILE_NAME for a60

    SQL> select FILE_ID, FILE_NAME FROM dba_data_files where TABLESPACE_NAME = 'L';

    FILE_ID FILE_NAME

    ---------- ------------------------------------------------------------

    5 +MSDATA/maa/datafile/l.266.798569345

    6 +MSDATA/maa/datafile/l.267.798570165

    7 +MSDATA/maa/datafile/l.268.798572257

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> backup as backupset tablespace l;

    4> }

    released channel: ORA_DISK_1

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 03:01:40

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a1: starting piece 1 at 06-NOV-2012 03:01:41

    channel a1: finished piece 1 at 06-NOV-2012 03:01:42

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030140_89j38o3g_.bkp tag=TAG20121106T030140 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:01:42

    Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:01:42

    piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606102_89j38pm8_.bkp comment=NONE

    Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:01:43

    released channel: a1

    -- 只产生了一个备份集

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> backup as backupset tablespace l filesperset 1;

    4> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 03:04:04

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel a1: starting piece 1 at 06-NOV-2012 03:04:05

    channel a1: finished piece 1 at 06-NOV-2012 03:04:06

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030405_89j3f5cl_.bkp tag=TAG20121106T030405 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    channel a1: starting piece 1 at 06-NOV-2012 03:04:06

    channel a1: finished piece 1 at 06-NOV-2012 03:04:07

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030405_89j3f6jq_.bkp tag=TAG20121106T030405 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a1: starting piece 1 at 06-NOV-2012 03:04:07

    channel a1: finished piece 1 at 06-NOV-2012 03:04:08

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030405_89j3f7o9_.bkp tag=TAG20121106T030405 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:04:08

    Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:04:08

    piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606248_89j3f98y_.bkp comment=NONE

    Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:04:09

    released channel: a1

    -- 产生了三个备份集

    并行度

    备份集的数量不会低于backup并行度的数量。若一次备份的输入文件是20个,但是DBA使用了4个并行度,结果至少产生4个备份集。

    切记不是使用了4个通道就能使用4个并行度,如果输入文件只有3个,充其量并行度为3.

    我们只设置了2个通道,结果是创建了2个备份集

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> allocate channel a2 device type disk;

    4> backup as backupset tablespace l;

    5> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    allocated channel: a2

    channel a2: SID=45 device type=DISK

    Starting backup at 06-NOV-2012 03:10:13

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a1: starting piece 1 at 06-NOV-2012 03:10:13

    channel a2: starting full datafile backup set

    channel a2: specifying datafile(s) in backup set

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    channel a2: starting piece 1 at 06-NOV-2012 03:10:13

    channel a1: finished piece 1 at 06-NOV-2012 03:10:14

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031013_89j3rojw_.bkp tag=TAG20121106T031013 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a2: finished piece 1 at 06-NOV-2012 03:10:14

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031013_89j3rokf_.bkp tag=TAG20121106T031013 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:10:14

    Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:10:14

    piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606614_89j3rq4c_.bkp comment=NONE

    Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:10:15

    released channel: a1

    released channel: a2

    设置了3个通道,产生了3个备份集

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> allocate channel a2 device type disk;

    4> allocate channel a3 device type disk;

    5> backup as backupset tablespace l;

    6> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    allocated channel: a2

    channel a2: SID=45 device type=DISK

    allocated channel: a3

    channel a3: SID=48 device type=DISK

    Starting backup at 06-NOV-2012 03:12:48

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel a1: starting piece 1 at 06-NOV-2012 03:12:48

    channel a2: starting full datafile backup set

    channel a2: specifying datafile(s) in backup set

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    channel a2: starting piece 1 at 06-NOV-2012 03:12:48

    channel a3: starting full datafile backup set

    channel a3: specifying datafile(s) in backup set

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a3: starting piece 1 at 06-NOV-2012 03:12:49

    channel a1: finished piece 1 at 06-NOV-2012 03:12:50

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031248_89j3xjyq_.bkp tag=TAG20121106T031248 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:02

    channel a2: finished piece 1 at 06-NOV-2012 03:12:50

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031248_89j3xk30_.bkp tag=TAG20121106T031248 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:02

    channel a3: finished piece 1 at 06-NOV-2012 03:12:50

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031248_89j3xk3t_.bkp tag=TAG20121106T031248 comment=NONE

    channel a3: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:12:50

    Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:12:50

    piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606770_89j3xlrw_.bkp comment=NONE

    Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:12:51

    released channel: a1

    released channel: a2

    released channel: a3

    输入文件的种类

    有些文件不能同在一个备份集中,若backup命令需要一起备份这样的文件,产生的备份集会预期的多。

    规则:数据文件、归档日志只能单独占用备份集,控制文件和参数文件可以合用备份集。

    我们先把自动控制文件备份关闭:

    RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;

    old RMAN configuration parameters:

    CONFIGURE CONTROLFILE AUTOBACKUP ON;

    new RMAN configuration parameters:

    CONFIGURE CONTROLFILE AUTOBACKUP OFF;

    new RMAN configuration parameters are successfully stored

    我们拿1号数据文件来测试,1号数据文件对应system表空间,它被备份,RMAN就会自动备份控制文件和参数文件。

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> backup as backupset datafile 1;

    4> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 03:33:38

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    channel a1: starting piece 1 at 06-NOV-2012 03:33:38

    channel a1: finished piece 1 at 06-NOV-2012 03:33:54

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T033338_89j54lyv_.bkp tag=TAG20121106T033338 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:16

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    including current control file in backup set

    including current SPFILE in backup set

    channel a1: starting piece 1 at 06-NOV-2012 03:33:55

    channel a1: finished piece 1 at 06-NOV-2012 03:33:56

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncsnf_TAG20121106T033338_89j553g0_.bkp tag=TAG20121106T033338 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:33:56

    released channel: a1

    -- 这里可以看到创建了两个备份集,这是因为数据文件和控制文件不兼容所致。

    那么非1号文件能不能自动备份控制文件?经过测试验证不会,下面是2号sysaux表空间对应的数据文件备份例子:

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> backup as backupset datafile 2;

    4> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 03:35:42

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

    channel a1: starting piece 1 at 06-NOV-2012 03:35:42

    channel a1: finished piece 1 at 06-NOV-2012 03:35:57

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T033542_89j58gdk_.bkp tag=TAG20121106T033542 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:15

    Finished backup at 06-NOV-2012 03:35:57

    released channel: a1

    -- 可见只有一个备份集。

    小括号的使用

    小括号起到隔离的作用,不在同一个小括号内的输入文件一定不在同一个备份集中,在同一个小括号内的输入文件不一定在同一个备份集中。

    下面两个使用了两个括号,生成了两个备份集,验证了第一句:不在同一个小括号内的输入文件一定不在同一个备份集中

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> backup as backupset

    4> (datafile 5) (datafile 6,7);

    5> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 03:40:11

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a1: starting piece 1 at 06-NOV-2012 03:40:11

    channel a1: finished piece 1 at 06-NOV-2012 03:40:12

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034011_89j5jvfz_.bkp tag=TAG20121106T034011 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel a1: starting piece 1 at 06-NOV-2012 03:40:12

    channel a1: finished piece 1 at 06-NOV-2012 03:40:13

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034011_89j5jwlm_.bkp tag=TAG20121106T034011 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:40:13

    released channel: a1

    下面这个示例也是用了两个小括号,结果产生了3个备份集,第二个小括号内输入文件有两个,结果产生了两个备份集,这就验证了第二句:在同一个小括号内的输入文件不一定在同一个备份集中

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> backup as backupset

    4> (datafile 5) (datafile 1,7);

    5> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 03:41:40

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a1: starting piece 1 at 06-NOV-2012 03:41:40

    channel a1: finished piece 1 at 06-NOV-2012 03:41:55

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034140_89j5mngj_.bkp tag=TAG20121106T034140 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:15

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel a1: starting piece 1 at 06-NOV-2012 03:41:55

    channel a1: finished piece 1 at 06-NOV-2012 03:41:56

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034140_89j5n403_.bkp tag=TAG20121106T034140 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    including current control file in backup set

    including current SPFILE in backup set

    channel a1: starting piece 1 at 06-NOV-2012 03:41:58

    channel a1: finished piece 1 at 06-NOV-2012 03:41:59

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncsnf_TAG20121106T034140_89j5n653_.bkp tag=TAG20121106T034140 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:41:59

    released channel: a1

    下面情况和上一种有点区别,我们依然使用了两个小括号,但却配置了3个通道,也说明并行度达到了3,于是依从并行度规则,生成3个备份集

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> allocate channel a2 device type disk;

    4> allocate channel a3 device type disk;

    5> backup as backupset

    6> (datafile 5,6) (datafile 7);

    7> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    allocated channel: a2

    channel a2: SID=45 device type=DISK

    allocated channel: a3

    channel a3: SID=48 device type=DISK

    Starting backup at 06-NOV-2012 03:45:11

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel a1: starting piece 1 at 06-NOV-2012 03:45:11

    channel a2: starting full datafile backup set

    channel a2: specifying datafile(s) in backup set

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    channel a2: starting piece 1 at 06-NOV-2012 03:45:12

    channel a3: starting full datafile backup set

    channel a3: specifying datafile(s) in backup set

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a3: starting piece 1 at 06-NOV-2012 03:45:12

    channel a1: finished piece 1 at 06-NOV-2012 03:45:13

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034511_89j5t81k_.bkp tag=TAG20121106T034511 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:02

    channel a2: finished piece 1 at 06-NOV-2012 03:45:13

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034511_89j5t84p_.bkp tag=TAG20121106T034511 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:01

    channel a3: finished piece 1 at 06-NOV-2012 03:45:13

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034511_89j5t85m_.bkp tag=TAG20121106T034511 comment=NONE

    channel a3: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:45:13

    released channel: a1

    released channel: a2

    released channel: a3

    下面示例设置了3个通道,但却在小括号内显式指派了通道,也说明并行度只有2,产生了2个备份集。

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> allocate channel a2 device type disk;

    4> allocate channel a3 device type disk;

    5> backup as backupset

    6> (datafile 5,6 channel a1) (datafile 7 channel a2);

    7> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    allocated channel: a2

    channel a2: SID=45 device type=DISK

    allocated channel: a3

    channel a3: SID=48 device type=DISK

    Starting backup at 06-NOV-2012 03:47:45

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    channel a1: starting piece 1 at 06-NOV-2012 03:47:45

    channel a2: starting full datafile backup set

    channel a2: specifying datafile(s) in backup set

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a2: starting piece 1 at 06-NOV-2012 03:47:45

    channel a1: finished piece 1 at 06-NOV-2012 03:47:46

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034745_89j5z1q9_.bkp tag=TAG20121106T034745 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a2: finished piece 1 at 06-NOV-2012 03:47:46

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034745_89j5z1so_.bkp tag=TAG20121106T034745 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:47:46

    released channel: a1

    released channel: a2

    released channel: a3

    "plus archivelog"子句

    如果是备份时使用了"plus archivelog"子句,RMAN会做一个"归档收尾",即切换当前在线日志 — 归档该日志 — 备份刚刚产生的归档日志。

    所以会出现一个额外的只有一个归档日志的备份集。

    RMAN> run {

    2> allocate channel a1 device type disk;

    3> allocate channel a2 device type disk;

    4> backup database plus archivelog;

    5> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    allocated channel: a2

    channel a2: SID=45 device type=DISK

    Starting backup at 06-NOV-2012 03:54:55

    current log archived

    channel a1: starting archived log backup set

    channel a1: specifying archived log(s) in backup set

    input archived log thread=1 sequence=40 RECID=1 STAMP=798598856

    channel a1: starting piece 1 at 06-NOV-2012 03:54:56

    channel a2: starting archived log backup set

    channel a2: specifying archived log(s) in backup set

    input archived log thread=1 sequence=41 RECID=2 STAMP=798609295

    channel a2: starting piece 1 at 06-NOV-2012 03:54:56

    channel a1: finished piece 1 at 06-NOV-2012 03:54:57

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_annnn_TAG20121106T035455_89j6dj3d_.bkp tag=TAG20121106T035455 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    channel a2: finished piece 1 at 06-NOV-2012 03:54:57

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_annnn_TAG20121106T035455_89j6dj6o_.bkp tag=TAG20121106T035455 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:54:57

    Starting backup at 06-NOV-2012 03:54:57

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

    channel a1: starting piece 1 at 06-NOV-2012 03:54:57

    channel a2: starting full datafile backup set

    channel a2: specifying datafile(s) in backup set

    input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel a2: starting piece 1 at 06-NOV-2012 03:54:58

    channel a1: finished piece 1 at 06-NOV-2012 03:55:23

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T035457_89j6dkvy_.bkp tag=TAG20121106T035457 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:26

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    channel a2: finished piece 1 at 06-NOV-2012 03:55:23

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T035457_89j6dlhj_.bkp tag=TAG20121106T035457 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:25

    channel a2: starting full datafile backup set

    channel a2: specifying datafile(s) in backup set

    including current SPFILE in backup set

    channel a2: starting piece 1 at 06-NOV-2012 03:55:23

    including current control file in backup set

    channel a1: starting piece 1 at 06-NOV-2012 03:55:24

    channel a2: finished piece 1 at 06-NOV-2012 03:55:24

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsnf_TAG20121106T035457_89j6fcv2_.bkp tag=TAG20121106T035457 comment=NONE

    channel a2: backup set complete, elapsed time: 00:00:01

    channel a1: finished piece 1 at 06-NOV-2012 03:55:25

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnnf_TAG20121106T035457_89j6fdtd_.bkp tag=TAG20121106T035457 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:55:25

    Starting backup at 06-NOV-2012 03:55:25

    current log archived

    channel a1: starting archived log backup set

    channel a1: specifying archived log(s) in backup set

    input archived log thread=1 sequence=42 RECID=3 STAMP=798609326

    channel a1: starting piece 1 at 06-NOV-2012 03:55:26

    channel a1: finished piece 1 at 06-NOV-2012 03:55:27

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_annnn_TAG20121106T035526_89j6fgjc_.bkp tag=TAG20121106T035526 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 03:55:27

    released channel: a1

    released channel: a2

    -- 这里一共产生了7个备份集,归档文件通过我配置两个通道生成两个备份集,数据文件通过两个通道生成了两个备份集,控制文件和参数文件各产生一个备份集,最后"plus archivelog"子句再生成了一个备份集。

    -- 这些备份集也从产生的备份片中就可以知道。

    多路传输

    在备份时,一个通道中,RMAN同时读取多个输入文件的数据并将其写入同一个备份片的操作称为多路传输。

    读取的输入文件的数量称为多路传输等级(Multiplexing Level),该等级等于以下3个数中的最小值:

    1)通道的maxopenfiles;

    2)通道的输入文件数;

    3)64或backup命令的filesperset。

    分析下面的示例:

    RMAN> run {

    2> allocate channel a1 device type disk maxopenfiles 2;

    3> backup database;

    4> }

    allocated channel: a1

    channel a1: SID=58 device type=DISK

    Starting backup at 06-NOV-2012 04:41:40

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

    input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    channel a1: starting piece 1 at 06-NOV-2012 04:41:41

    channel a1: finished piece 1 at 06-NOV-2012 04:42:06

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T044140_89j9454l_.bkp tag=TAG20121106T044140 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:25

    channel a1: starting full datafile backup set

    channel a1: specifying datafile(s) in backup set

    including current control file in backup set

    including current SPFILE in backup set

    channel a1: starting piece 1 at 06-NOV-2012 04:42:07

    channel a1: finished piece 1 at 06-NOV-2012 04:42:08

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncsnf_TAG20121106T044140_89j94zfc_.bkp tag=TAG20121106T044140 comment=NONE

    channel a1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 04:42:08

    released channel: a1

    – 其中maxopenfiles设置了2,filesperset没有设置,所以取64,通道输入的文件数是7,其中取最小值就是2,也就是多路传输等级为2.

    RMAN每次只读两个数据文件,分三批写入备份片o1_mf_nnndf_TAG20121106T044140_89j9454l_.bkp,另外控制文件盒参数文件同时写入到

    o1_mf_ncsnf_TAG20121106T044140_89j94zfc_.bkp备份片里面。

    多路传输等级会影响通道在读阶段分配的输入缓冲的大小:

    1)当等级小于或等于4时,输入缓冲由16个1MB的缓冲组成;

    2)当等级大于4且小于或等于8时,输入缓冲由多个512KB的缓冲组成,但总大小小于16MB;

    3)当等级大于8时,每个输入文件将分配4个128KB的缓冲,即总大小等于512KB与等级的积。

    在备份时,RMAN给DISK通道的输出缓冲分配4个1MB总大小为4MB的缓冲。在还原时输出缓冲变成输入缓冲数量和大小不变。

    在还原时,也就是执行restore命令时,RMAN会从备份片中提取出原始的输入文件。此时,每个通道的输入缓冲和输出缓冲同为4个1MB总大小为4MB的缓冲。

    数据文件增量备份

    增量备份只"关心"在前一次备份之后发生变化的数据块,其优点在于产生备份片较小及使用它们恢复的速度比使用归档日志快。

    backup命令的incremental子句可以生成3种增量备份集:

    1)等级0增量备份。这是增量备份的基准备份,其备份的量与全备份一样多,所以并不是真正的增量备份,但是作为真正的增量备份之前必须要存在的备份。

    RMAN> backup incremental level 0 database;

    Starting backup at 06-NOV-2012 11:15:37

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=45 device type=DISK

    allocated channel: ORA_DISK_2

    channel ORA_DISK_2: SID=34 device type=DISK

    channel ORA_DISK_1: starting incremental level 0 datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:15:39

    channel ORA_DISK_2: starting incremental level 0 datafile backup set

    channel ORA_DISK_2: specifying datafile(s) in backup set

    input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:15:39

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:16:05

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd0_TAG20121106T111538_89k06vfh_.bkp tag=TAG20121106T111538 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26

    channel ORA_DISK_1: starting incremental level 0 datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:16:05

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd0_TAG20121106T111538_89k06w01_.bkp tag=TAG20121106T111538 comment=NONE

    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:26

    channel ORA_DISK_2: starting incremental level 0 datafile backup set

    channel ORA_DISK_2: specifying datafile(s) in backup set

    including current SPFILE in backup set

    channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:16:05

    including current control file in backup set

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:16:06

    channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:16:06

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsn0_TAG20121106T111538_89k07ovd_.bkp tag=TAG20121106T111538 comment=NONE

    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:16:07

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnn0_TAG20121106T111538_89k07pr5_.bkp tag=TAG20121106T111538 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 11:16:07

    2)等级1累计增量备份。这种增量备份只与等级0增量备份比较。若当前数据文件中的数据块与前次等级0增量备份中的不同,则加以备份,否则既跳过此数据块。这种备份虽然产生的备份片不是最小,但回复的速度快。

    SQL> grant dba to luocs identified by oracle;

    Grant succeeded.

    SQL> create table luocs.t1 as select * from dba_objects;

    Table created.

    RMAN> backup cumulative incremental level 1 database;

    Starting backup at 06-NOV-2012 11:34:54

    using channel ORA_DISK_1

    using channel ORA_DISK_2

    channel ORA_DISK_1: starting incremental level 1 datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:34:55

    channel ORA_DISK_2: starting incremental level 1 datafile backup set

    channel ORA_DISK_2: specifying datafile(s) in backup set

    input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:34:56

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:35:21

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113455_89k1c08z_.bkp tag=TAG20121106T113455 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26

    channel ORA_DISK_1: starting incremental level 1 datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:35:21

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113455_89k1c4p7_.bkp tag=TAG20121106T113455 comment=NONE

    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25

    channel ORA_DISK_2: starting incremental level 1 datafile backup set

    channel ORA_DISK_2: specifying datafile(s) in backup set

    including current SPFILE in backup set

    channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:35:21

    including current control file in backup set

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:35:22

    channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:35:22

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsn1_TAG20121106T113455_89k1csxv_.bkp tag=TAG20121106T113455 comment=NONE

    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:35:23

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnn1_TAG20121106T113455_89k1cttp_.bkp tag=TAG20121106T113455 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 11:35:23

    如果在执行上述命令的时候尚未创建等级0增量备份,则RMAN会自动将等级降为0。

    3)等级1差异增量备份。这种增量备份可以与等级0连同等级1(不论是累计还是差异的)增量备份比较。这种备份产生的备份片相对来说最小。

    RMAN> backup incremental level 1 database;

    Starting backup at 06-NOV-2012 11:39:58

    using channel ORA_DISK_1

    using channel ORA_DISK_2

    channel ORA_DISK_1: starting incremental level 1 datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:39:59

    channel ORA_DISK_2: starting incremental level 1 datafile backup set

    channel ORA_DISK_2: specifying datafile(s) in backup set

    input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:39:59

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:40:25

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113958_89k1nhcc_.bkp tag=TAG20121106T113958 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26

    channel ORA_DISK_1: starting incremental level 1 datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:40:25

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113958_89k1np4p_.bkp tag=TAG20121106T113958 comment=NONE

    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:26

    channel ORA_DISK_2: starting incremental level 1 datafile backup set

    channel ORA_DISK_2: specifying datafile(s) in backup set

    including current SPFILE in backup set

    channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:40:25

    including current control file in backup set

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:40:26

    channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:40:26

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsn1_TAG20121106T113958_89k1o9k2_.bkp tag=TAG20121106T113958 comment=NONE

    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:40:27

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnn1_TAG20121106T113958_89k1obj0_.bkp tag=TAG20121106T113958 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 11:40:27

    将来介质恢复时,执行recover命令会自动使用它们。

    镜像复制备份

    镜像复制备份是一种极为简单的备份方式,类似于直接使用操作系统的复制命令,备份文件就是输入文件的一份副本,与镜像复制相比,备份集备份好比一个压缩包。

    镜像复制的数量和大小均与输入文件一模一样,这样做的缺点是空间的使用无法优化;优点是可大大缩减还原操作的时间,那就是用重命名代替restore还原命令。比如将来哪个数据文件损坏了就将其在控制文件中的路径修改成镜像复制的路径,还原操作即可完成,此操作需要时间极短,与文件的大小无关。

    创建镜像复制备份,需要使用as copy子句,或者通过"configure device type"命令修改通道的默认属性,使backup命令默认使用镜像复制作为备份类型。

    L表空间有三个数据文件,从备份输出可以看出三个数据文件各自产生3个镜像,都存放到了闪回恢复区。

    RMAN> backup as copy tablespace l;

    Starting backup at 06-NOV-2012 11:53:37

    using channel ORA_DISK_1

    using channel ORA_DISK_2

    channel ORA_DISK_1: starting datafile copy

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel ORA_DISK_2: starting datafile copy

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2g1md_.dbf tag=TAG20121106T115337 RECID=1 STAMP=798638018

    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

    channel ORA_DISK_1: starting datafile copy

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2g1mj_.dbf tag=TAG20121106T115337 RECID=2 STAMP=798638018

    channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2g2qk_.dbf tag=TAG20121106T115337 RECID=3 STAMP=798638018

    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 11:53:39

    RMAN> configure device type disk backup type to copy;

    old RMAN configuration parameters:

    CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;

    new RMAN configuration parameters:

    CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 2;

    Configure device type配置之后不加as copy子句也进行了镜像备份:

    RMAN> backup tablespace l;

    Starting backup at 06-NOV-2012 11:55:42

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=45 device type=DISK

    allocated channel: ORA_DISK_2

    channel ORA_DISK_2: SID=34 device type=DISK

    channel ORA_DISK_1: starting datafile copy

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel ORA_DISK_2: starting datafile copy

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2kz89_.dbf tag=TAG20121106T115542 RECID=4 STAMP=798638143

    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

    channel ORA_DISK_1: starting datafile copy

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2kzfz_.dbf tag=TAG20121106T115542 RECID=5 STAMP=798638143

    channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2l0gg_.dbf tag=TAG20121106T115542 RECID=6 STAMP=798638144

    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 11:55:45

    注意,镜像复制备份是不可以使用SBT设备的。鉴于只有当镜像复制在磁盘上时才能有效地缩短还原地时间,所以Oracle认为此类备份存放在SBT设备上没有意义。

    RMAN> run {

    2> allocate channel a1 device type sbt

    3> parms 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/sbt1)';

    4> backup as copy tablespace l;

    5> }

    released channel: ORA_DISK_1

    released channel: ORA_DISK_2

    allocated channel: a1

    channel a1: SID=45 device type=SBT_TAPE

    channel a1: WARNING: Oracle Test Disk API

    Starting backup at 06-NOV-2012 11:59:15

    released channel: a1

    RMAN-00571: ===========================================================

    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

    RMAN-00571: ===========================================================

    RMAN-03002: failure of backup command at 11/06/2012 11:59:15

    RMAN-06583: at least 1 channel of TYPE DISK must be allocated to use AS COPY option

    -- 注意最后一句:RMAN-06583: at least 1 channel of TYPE DISK must be allocated to use AS COPY option

    下面示例是使用一个通道备份4到7号数据文件,镜像备份在闪回恢复区里

    RMAN> run{

    2> allocate channel a1 device type disk;

    3> backup as copy datafile 4,5,6,7;

    4> }

    allocated channel: a1

    channel a1: SID=45 device type=DISK

    Starting backup at 06-NOV-2012 12:01:47

    channel a1: starting datafile copy

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2xcx7_.dbf tag=TAG20121106T120147 RECID=7 STAMP=798638508

    channel a1: datafile copy complete, elapsed time: 00:00:01

    channel a1: starting datafile copy

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2xf4h_.dbf tag=TAG20121106T120147 RECID=8 STAMP=798638509

    channel a1: datafile copy complete, elapsed time: 00:00:01

    channel a1: starting datafile copy

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2xg9f_.dbf tag=TAG20121106T120147 RECID=9 STAMP=798638510

    channel a1: datafile copy complete, elapsed time: 00:00:01

    channel a1: starting datafile copy

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    output file name=/u01/recovery/MAA/datafile/o1_mf_users_89k2xhgn_.dbf tag=TAG20121106T120147 RECID=10 STAMP=798638511

    channel a1: datafile copy complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 12:01:52

    released channel: a1

    下面示例是使用两个通道备份4~7号数据文件,指定了非闪回恢复区作为目的地

    RMAN> run {

    2> allocate channel a1 device type disk to destination '/u01/bak/disk1';

    3> allocate channel a2 device type disk to destination '/u01/bak/disk2';

    4> backup as copy (datafile 4) (datafile 5,6,7);

    5> }

    allocated channel: a1

    channel a1: SID=45 device type=DISK

    allocated channel: a2

    channel a2: SID=34 device type=DISK

    Starting backup at 06-NOV-2012 12:04:23

    channel a1: starting datafile copy

    input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

    channel a2: starting datafile copy

    input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

    output file name=/u01/bak/disk1/MAA/datafile/o1_mf_l_89k3286j_.dbf tag=TAG20121106T120423 RECID=11 STAMP=798638664

    channel a1: datafile copy complete, elapsed time: 00:00:01

    channel a1: starting datafile copy

    input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

    output file name=/u01/bak/disk2/MAA/datafile/o1_mf_l_89k328dv_.dbf tag=TAG20121106T120423 RECID=12 STAMP=798638664

    channel a2: datafile copy complete, elapsed time: 00:00:01

    channel a2: starting datafile copy

    input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

    output file name=/u01/bak/disk1/MAA/datafile/o1_mf_l_89k329fj_.dbf tag=TAG20121106T120423 RECID=13 STAMP=798638665

    channel a1: datafile copy complete, elapsed time: 00:00:01

    output file name=/u01/bak/disk2/MAA/datafile/o1_mf_users_89k329lg_.dbf tag=TAG20121106T120423 RECID=14 STAMP=798638665

    channel a2: datafile copy complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 12:04:26

    released channel: a1

    released channel: a2

    -- 从输出信息中可以看出,尽管我们用小括号绑了5,6,7号三个数据文件,但它们加上4号备份文件平均使用两个通道备份。

    创建控制文件的镜像复制

    RMAN> backup as copy current controlfile;

    Starting backup at 06-NOV-2012 12:14:23

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=45 device type=DISK

    allocated channel: ORA_DISK_2

    channel ORA_DISK_2: SID=34 device type=DISK

    channel ORA_DISK_1: starting datafile copy

    copying current control file

    output file name=/u01/recovery/MAA/controlfile/o1_mf_TAG20121106T121424_89k3o09m_.ctl tag=TAG20121106T121424 RECID=15 STAMP=798639264

    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 12:14:25

    将所有归档日志复制一份到闪回恢复区

    RMAN> backup as copy archivelog all;

    Starting backup at 06-NOV-2012 12:15:09

    current log archived

    using channel ORA_DISK_1

    using channel ORA_DISK_2

    channel ORA_DISK_1: starting archived log copy

    input archived log thread=1 sequence=40 RECID=1 STAMP=798598856

    channel ORA_DISK_2: starting archived log copy

    input archived log thread=1 sequence=41 RECID=2 STAMP=798609295

    output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_41_89k3pgbq_.arc RECID=5 STAMP=798639310

    channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:01

    channel ORA_DISK_2: starting archived log copy

    input archived log thread=1 sequence=42 RECID=3 STAMP=798609326

    output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_40_89k3pg9o_.arc RECID=6 STAMP=798639312

    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:02

    channel ORA_DISK_1: starting archived log copy

    input archived log thread=1 sequence=43 RECID=4 STAMP=798639309

    output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_42_89k3phrs_.arc RECID=7 STAMP=798639312

    channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:01

    output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_43_89k3pjwh_.arc RECID=8 STAMP=798639313

    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 12:15:13

    这里有个特殊的,参数文件尽管我们通过as copy做个镜像复制备份,但却依然产生了备份集,这表示RMAN不会对参数文件支持镜像复制备份

    RMAN> backup as copy spfile;

    Starting backup at 06-NOV-2012 12:16:03

    using channel ORA_DISK_1

    using channel ORA_DISK_2

    channel ORA_DISK_1: starting full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    including current SPFILE in backup set

    channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 12:16:03

    channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 12:16:04

    piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsnf_TAG20121106T121603_89k3r3m5_.bkp tag=TAG20121106T121603 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 06-NOV-2012 12:16:04

    展开全文
  • 本节内容主要包括:概述备份目录管理备份集管理备份信息查看1. 概述管理备份一个重要的目的是删除不再需要的备份,DM7没有提供自动删除过期备份的功能,删除备份需要手动执行。备份管理相关系统过程与函数总结如下:...

    下面介绍如何使用DIsql工具管理数据库备份、表空间备份、表备份,以及归档备份。本节内容主要包括:

    1. 概述
    2. 备份目录管理
    3. 备份集管理
    4. 备份信息查看

    1. 概述

    管理备份一个重要的目的是删除不再需要的备份,DM7没有提供自动删除过期备份的功能,删除备份需要手动执行。备份管理相关系统过程与函数总结如下:

    SF_BAKSET_BACKUP_DIR_ADD:添加备份目录。SF_BAKSET_BACKUP_DIR_REMOVE:指定删除内存中的备份目录。SF_BAKSET_BACKUP_DIR_REMOVE_ALL:删除内存中全部的备份目录。SF_BAKSET_CHECK:对备份集进行校验。SF_BAKSET_REMOVE:删除指定设备类型和指定备份集目录的备份集。SF_BAKSET_REMOVE_BATCH:批量删除满足指定条件的所有备份集。SP_DB_BAKSET_REMOVE_BATCH:批量删除指定时间之前的数据库备份集。SP_TS_BAKSET_REMOVE_BATCH:批量删除指定表空间对象及指定时间之前的表空间备份集。SP_TAB_BAKSET_REMOVE_BATCH:批量删除指定表对象及指定时间之前的表备份集。SP_ARCH_BAKSET_REMOVE_BATCH:批量删除指定条件的归档备份集。

    备份管理相关动态视图总结如下:

    V$BACKUPSET:显示备份集基本信息。V$BACKUPSET_DBINFO:显示备份集的数据库相关信息。V$BACKUPSET_DBF:显示备份集中数据文件的相关信息。V$BACKUPSET_ARCH:显示备份集的归档信息。V$BACKUPSET_BKP:显示备份集的备份片信息。V$BACKUPSET_SEARCH_DIRS:显示备份集搜索目录。V$BACKUPSET_TABLE:显示表备份集中备份表信息。V$BACKUPSET_SUBS:显示并行备份中生成的子备份集信息。

    SFBAKSETBACKUPDIRADD添加备份目录仅对当前会话有效。调用删除备份等函数或查看动态视图时要先调用SFBAKSETBACKUPDIRADD添加备份目录,否则仅搜索默认备份路径下的备份集。

    2. 备份目录管理

    这里的备份目录是指备份集搜索目录,这些目录被记录在内存中,当执行动态视图(参见3.2.4.4 备份信息查看)或批量删除备份集时,均会从这些指定目录中先搜索所有备份集信息。

    本节主要内容包括:

     SF_BAKSET_BACKUP_DIR_ADD SF_BAKSET_BACKUP_DIR_REMOVE SF_BAKSET_BACKUP_DIR_REMOVE_ALLSF_BAKSET_BACKUP_DIR_ADD函数

    添加备份目录。若添加目录已经存在或者为库默认备份路径,则认为已经存在,不添加,但也不报错。 定义:

    INT SF_BAKSET_BACKUP_DIR_ADD(device_type varchar,backup_dir varchar(256))

    参数说明:

    device_type:待添加的备份目录对应存储介质类型,DISK或者TAPE。

    backup_dir:待添加的备份目录。

    返回值:

    1:目录添加成功;其它情况下报错。

    举例说明:

    SQL> select sf_bakset_backup_dir_add('disk','arch_backup_lsn_15092082_15092086');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','arch_backup_lsn_15092082_15092086')---------- --------------------------------------------------------------------1          1used time: 26.411(ms). Execute id is 1569.

    SFBAKSETBACKUPDIRREMOVE函数

    删除备份目录。若删除目录为库默认备份路径,不进行删除,认为删除失败。若指定目录存在于记录的合法目录中,则删除;不存在或者为空则跳过,正常返回。

    定义:

    INT SF_BAKSET_BACKUP_DIR_REMOVE (device_type varchar,backup_dir varchar(256))

    参数说明:

    device_type:待删除的备份目录对应存储介质类型。待删除的备份目录对应存储介质类型,DISK或者TAPE。

    backup_dir:待删除的备份目录。

    返回值:

    1:目录删除成功;其他情况报错。

    举例说明:

    SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- -----------------------------------1          arch_backup_lsn_15092082_150920862          /dm_home/dmdba/dmdbms/data/jydm/bakused time: 36.620(ms). Execute id is 1573.SQL> select sf_bakset_backup_dir_remove('disk','arch_backup_lsn_15092082_15092086');LINEID     SF_BAKSET_BACKUP_DIR_REMOVE('disk','arch_backup_lsn_15092082_15092086')---------- -----------------------------------------------------------------------1          1used time: 1.057(ms). Execute id is 1575.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- -----------------------------------1          /dm_home/dmdba/dmdbms/data/jydm/bakused time: 0.987(ms). Execute id is 1577.

    SFBAKSETBACKUPDIRREMOVE_ALL函数清理全部备份目录,默认备份目录除外。

    定义:

    INT SF_BAKSET_BACKUP_DIR_REMOVE_ALL ()

    返回值:

    1:目录全部清理成功;其它情况下报错。

    举例说明:

    SQL> select sf_bakset_backup_dir_remove_all();LINEID     SF_BAKSET_BACKUP_DIR_REMOVE_ALL()---------- ---------------------------------1          1used time: 1.019(ms). Execute id is 1580.

    3. 备份集管理(备份集校验与删除)

    本节介绍备份管理中最重要的功能,备份集校验和备份集删除。单个备份集删除时并行备份中地子备份集不允许单独删除;在给定备份集搜集目录中发现存在引用删除备份集作为基备份的需要执行级联删除,默认报错。批量删除备份集时,跳过收集到的单独的子备份集。主要内容如下:

     SF_BAKSET_CHECK SF_BAKSET_REMOVE SF_BAKSET_REMOVE_BATCH SP_DB_BAKSET_REMOVE_BATCH SP_TS_BAKSET_REMOVE_BATCH SP_TAB_BAKSET_REMOVE_BATCH SP_ARCH_BAKSET_REMOVE_BATCH

    SFBAKSETCHECK函数对备份集进行校验。

    定义:

    INT SF_BAKSET_CHECK(device_type varchar,bakset_pathvarchar(256))

    参数说明:

    device_type:设备类型,disk或tape。

    bakset_path:待校验的备份集目录。

    返回值:

    1:备份集目录存在且合法;否则报错。

    举例说明:

    SQL> backup database full to db_rac_bak_for_check backupset '/dm7/backup/db_rac_bak_for_check';executed successfullyused time: 00:00:01.410. Execute id is 158.SQL> select sf_bakset_check('disk','/dm7/backup/db_rac_bak_for_check');LINEID     SF_BAKSET_CHECK('disk','/dm7/backup/db_rac_bak_for_check')---------- ----------------------------------------------------------1          1used time: 12.669(ms). Execute id is 159.SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_bak_for_check');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_bak_for_check')---------- -------------------------------------------------------------------1          1used time: 1.610(ms). Execute id is 162.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- --------------------------------1          /dm7/backup/db_rac_bak_for_check2          +DMDATA/data/rac/bakused time: 0.770(ms). Execute id is 163.SQL> select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME          BACKUP_PATH                      TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- -------------------- -------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        53418202    -1          DB_RAC_BAK_FOR_CHECK /dm7/backup/db_rac_bak_for_check 0           0           1           rac         -1                    2020-05-29 21:14:50.000773        0            0              0           0           33554432    50908                51113                2           4           1            0           0           49398                117507596    0used time: 00:00:01.023. Execute id is 164.

    SFBAKSETREMOVE函数

    删除指定设备类型和指定备份集目录的备份集。一次只检查一个合法.meta文件,然后删除对应备份集;若存在非法或非正常备份的.meta文件,则报错或直接返回,不会接着检查下一个.meta文件;若同一个备份集下还存在其它备份文件或备份集,则只删除备份文件,不会删除整个备份集。

    定义:

    INT SF_BAKSET_REMOVE (device_type varchar,backsetpath varchar(256),option integer)

    参数说明:

    device_type:设备类型,disk或tape。

    backsetpath:待删除的备份集目录。

    Option:删除备份集选项,0默认删除,1级联删除。可选参数。并行备份集中子备份集不允许单独删除。目标备份集被其他备份集引用为基备份的,默认删除,报错;级联删除情况下,会递归将相关的增量备份也删除。

    返回值:

    1:备份集目录删除成功,其它情况下报错。

    举例说明:

    SQL> backup database full to db_rac_bak_for_remove backupset '/dm7/backup/db_rac_bak_for_remove';executed successfullyused time: 00:00:01.320. Execute id is 165.SQL> backup database increment base on backupset '/dm7/backup/db_rac_bak_for_remove' backupset '/dm7/backup/db_rac_bak_for_remove_incr';executed successfullyused time: 00:00:01.255. Execute id is 170.SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_bak_for_remove');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_bak_for_remove')---------- --------------------------------------------------------------------1          1used time: 1.836(ms). Execute id is 171.SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_bak_for_remove_incr');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_bak_for_remove_incr')---------- -------------------------------------------------------------------------1          1used time: 1.444(ms). Execute id is 172.SQL> select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME                        BACKUP_PATH                            TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME             BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- ---------------------------------- -------------------------------------- ----------- ----------- ----------- ----------- ----------- --------------------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        53418202    -1          DB_RAC_BAK_FOR_CHECK               /dm7/backup/db_rac_bak_for_check       0           0           1           rac         -1                                2020-05-29 21:14:50.000773        0            0              0           0           33554432    50908                51113                2           4           1            0           0           49398                117507596    02          DISK        1763138770  -1          DB_RAC_BAK_FOR_REMOVE              /dm7/backup/db_rac_bak_for_remove      0           0           1           rac         -1                                2020-05-29 22:00:34.000524        0            0              0           0           33554432    50908                51119                2           4           1            0           0           49398                117507596    03          DISK        -1036285990 -1          DB_INCR_rac_20200529_220232_000624 /dm7/backup/db_rac_bak_for_remove_incr 1           0           1           rac         -1          DB_RAC_BAK_FOR_REMOVE 2020-05-29 22:02:33.000834        0            0              0           0           33554432    50908                51135                2           4           1            0           0           49398                117507596    0used time: 00:00:01.038. Execute id is 173.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- --------------------------------------1          /dm7/backup/db_rac_bak_for_check2          /dm7/backup/db_rac_bak_for_remove3          /dm7/backup/db_rac_bak_for_remove_incr4          +DMDATA/data/rac/bakused time: 0.781(ms). Execute id is 174.SQL> select sf_bakset_remove('disk','/dm7/backup/db_rac_bak_for_remove');select sf_bakset_remove('disk','/dm7/backup/db_rac_bak_for_remove');[-8202]:Be the base backupset of /dm7/backup/db_rac_bak_for_remove_incr,cannot be removed.used time: 00:00:01.023. Execute id is 0.

    报错了,提示说它是另一个备份集的基备份不能被删除

    SQL> select sf_bakset_remove('disk','/dm7/backup/db_rac_bak_for_remove',1);LINEID     SF_BAKSET_REMOVE('disk','/dm7/backup/db_rac_bak_for_remove',1)---------- --------------------------------------------------------------1          1used time: 50.201(ms). Execute id is 176.

    检查备份集可以确认在删除基备份时确实级联删除了增量备份

    SQL> select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME          BACKUP_PATH                      TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- -------------------- -------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        53418202    -1          DB_RAC_BAK_FOR_CHECK /dm7/backup/db_rac_bak_for_check 0           0           1           rac         -1                    2020-05-29 21:14:50.000773        0            0              0           0           33554432    50908                51113                2           4           1            0           0           49398                117507596    0used time: 00:00:01.050. Execute id is 177.

    SFBAKSETREMOVE_BATCH函数

    批量删除满足指定条件的所有备份集。

    定义:

    INT SF_BAKSET_REMOVE_BATCH (device_type varchar,end_time datetime,range int,obj_name varchar(257))

    参数说明:

    device_type:设备类型,disk或tape。指定NULL,则忽略存储设备的区分。

    endtime:删除备份集生成的结束时间,仅删除endtime之前的备份集,必须指定。

    range:指定删除备份的级别。1代表库级,2代表表空间级,3代表表级,4代表归档备份。若指定NULL,则忽略备份集备份级别的区分。

    obj_name:待删除备份集中备份对象的名称,仅表空间级和表级有效。若为表级备份删除,则需指定完整的表名(模式.表名),否则,将认为删除会话当前模式下的表备份。若指定为NULL,则忽略备份集中备份对象名称区分

    返回值:

    1:备份集目录删除成功,其它情况下报错。

    举例说明:

    SQL> backup database full to db_rac_full_bak_for_remove backupset '/dm7/backup/db_rac_full_bak_for_remove';executed successfullyused time: 00:00:01.498. Execute id is 184.SQL> backup tablespace main full to tab_main_full_bak_for_remove backupset '/dm7/backup/tab_main_full_bak_for_remove';executed successfullyused time: 00:00:01.121. Execute id is 185.SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_full_bak_for_remove');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_full_bak_for_remove')---------- -------------------------------------------------------------------------1          1used time: 1.574(ms). Execute id is 186.SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/tab_main_full_bak_for_remove');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/tab_main_full_bak_for_remove')---------- ---------------------------------------------------------------------------1          1used time: 1.881(ms). Execute id is 187.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- ----------------------------------------1          /dm7/backup/db_rac_full_bak_for_remove2          /dm7/backup/tab_main_full_bak_for_remove3          +DMDATA/data/rac/bakused time: 0.784(ms). Execute id is 188.SQL>  select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME                  BACKUP_PATH                              TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- ---------------------------- ---------------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        760083173   -1          DB_RAC_FULL_BAK_FOR_REMOVE   /dm7/backup/db_rac_full_bak_for_remove   0           0           1           rac         -1                    2020-05-30 10:21:23.000661        0            0              0           0           33554432    50908                51141                2           4           1            0           0           49398                117507596    02          DISK        -1117064059 -1          TAB_MAIN_FULL_BAK_FOR_REMOVE /dm7/backup/tab_main_full_bak_for_remove 0           0           2           MAIN        4                     2020-05-30 10:22:41.000744        0            0              0           0           33554432    50908                51147                1           1           1            0           0           49398                117507596    0used time: 00:00:01.025. Execute id is 189.SQL> select sf_bakset_remove_batch('disk',now(),null,null);LINEID     SF_BAKSET_REMOVE_BATCH('disk',NOW(),NULL,NULL)---------- ----------------------------------------------1          1used time: 21.228(ms). Execute id is 190.SQL> select * from v$backupset;no rowsused time: 00:00:01.023. Execute id is 191.

    SPDBBAKSETREMOVEBATCH过程批量删除指定时间之前的数据库备份集。使用该方法前,需要先使用SFBAKSETBACKUPDIRADD添加将要删除的备份集目录,否则只删除默认备份路径下的备份集。

    定义:

    SP_DB_BAKSET_REMOVE_BATCH (device_type varchar,end_time datetime)

    参数说明:

    device_type:设备类型,disk或tape。指定NULL,则忽略存储设备的区分。

    endtime:删除备份集生成的结束时间,仅删除endtime之前的备份集,必须指定。

    举例说明:

    SQL> backup database full to db_rac_full_bak_for_del backupset '/dm7/backup/db_rac_full_bak_for_del';executed successfullyused time: 00:00:01.580. Execute id is 194.SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_full_bak_for_del');LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_full_bak_for_del')---------- ----------------------------------------------------------------------1          1used time: 1.725(ms). Execute id is 195.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- -----------------------------------1          /dm7/backup/db_rac_full_bak_for_del2          +DMDATA/data/rac/bakused time: 0.483(ms). Execute id is 196.SQL> select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME             BACKUP_PATH                         TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- ----------------------- ----------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        361744824   -1          DB_RAC_FULL_BAK_FOR_DEL /dm7/backup/db_rac_full_bak_for_del 0           0           1           rac         -1                    2020-05-30 10:27:00.000621        0            0              0           0           33554432    50908                51153                2           4           1            0           0           49398                117507596    0used time: 00:00:01.024. Execute id is 197.SQL> call sp_db_bakset_remove_batch('disk',now());DMSQL executed successfullyused time: 36.535(ms). Execute id is 198.SQL> select * from v$backupset;no rowsused time: 00:00:01.021. Execute id is 199.

    SPTSBAKSETREMOVEBATCH过程批量删除指定表空间对象及指定时间之前的表空间备份集。使用该方法前,需要先使用SFBAKSETBACKUPDIRADD添加将要删除的备份集目录,否则只删除默认备份路径下的备份集。

    定义:

    SP_TS_BAKSET_REMOVE_BATCH (device_type varchar,end_time datetime,ts_name varchar(128))

    参数说明:

    device_type:设备类型,disk或tape。指定NULL,则忽略存储设备的区分。

    endtime:删除备份集生成的结束时间,仅删除endtime之前的备份集,必须指定。

    ts_name:表空间名,若未指定,则认为删除所有满足条件的表空间备份集。

    举例说明:

    SQL> backup tablespace main full to tab_main_bak_full_for_del backupset '/dm7/backup/tab_main_bak_full_for_del';executed successfullyused time: 00:00:01.123. Execute id is 202.SQL> sf_bakset_backup_dir_add('disk','/dm7/backup/tab_main_bak_full_for_del');DMSQL executed successfullyused time: 1.256(ms). Execute id is 203.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- -------------------------------------1          /dm7/backup/tab_main_bak_full_for_del2          +DMDATA/data/rac/bakused time: 0.773(ms). Execute id is 204.SQL> select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME               BACKUP_PATH                           TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- ------------------------- ------------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        798489856   -1          TAB_MAIN_BAK_FULL_FOR_DEL /dm7/backup/tab_main_bak_full_for_del 0           0           2           MAIN        4                     2020-05-30 10:38:29.000350        0            0              0           0           33554432    50908                51159                1           1           1            0           0           49398                117507596    0used time: 00:00:01.027. Execute id is 205.SQL> call sp_ts_bakset_remove_batch('disk',now(),'main');DMSQL executed successfullyused time: 16.765(ms). Execute id is 206.SQL> select * from v$backupset;LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME               BACKUP_PATH                           TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE---------- ----------- ----------- ----------- ------------------------- ------------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------1          DISK        798489856   -1          TAB_MAIN_BAK_FULL_FOR_DEL /dm7/backup/tab_main_bak_full_for_del 0           0           2           MAIN        4                     2020-05-30 10:38:29.000350        0            0              0           0           33554432    50908                51159                1           1           1            0           0           49398                117507596    0used time: 00:00:01.022. Execute id is 207.

    说明指定表空间名时表空间名要大写

    SQL> call sp_ts_bakset_remove_batch('disk',now(),'MAIN');DMSQL executed successfullyused time: 13.667(ms). Execute id is 208.SQL> select * from v$backupset;no rowsused time: 00:00:01.023. Execute id is 209.

    删除备份目录

    SQL> sf_bakset_backup_dir_remove_all();DMSQL executed successfullyused time: 0.787(ms). Execute id is 210.SQL> select * from v$backupset_search_dirs;LINEID     DIR---------- --------------------1          +DMDATA/data/rac/bakused time: 0.836(ms). Execute id is 211.

    SPTABBAKSETREMOVEBATCH过程批量删除指定表对象及指定时间之前的表备份集。使用该方法前,需要先使用SFBAKSETBACKUPDIRADD添加将要删除的备份集目录,否则只删除默认备份路径下的备份集。

    定义:

    SP_TAB_BAKSET_REMOVE_BATCH (device_type varchar,end_time datetime,sch_name varchar(128),tab_name varchar(128))

    ...

    ✨ 接下来内容请访问原文(https://www.modb.pro/db/28694?YYF)进行查看~

    更多数据库相关内容,可访问墨天轮(https://www.modb.pro/?YYF)进行浏览。

    5fdd31f0e34bc95ab04dd90724ac2f65.png
    展开全文
  • 可使用SQL Server Standard 中的SQL 维护向导安排计划备份文件库数据库的时间。必须使用计划文件备份软件定期备份所有存档服务器上的物理文件库存档。备份库时,对于仍处于检出状态和在客户端工作站中被修改的文件中...

    前言:文件库备份必须成为日常管理SOLIDWORKS PDM 的一部分。在升级SOLIDWORKS EPDM 组件前,也要进行文件库备份。

    可使用SQL Server Standard 中的SQL 维护向导安排计划备份文件库数据库的时间。必须使用计划文件备份软件定期备份所有存档服务器上的物理文件库存档。

    备份库时,对于仍处于检出状态和在客户端工作站中被修改的文件中的最新更新,虽然它们也存储在客户端的本地文件库视图(缓存)中,但仍然不包括在备份当中。为确保备份中始终包括所有文件的最新信息,应当检入这些文件。同时要确保所有使用人员下线完整的文件库备份必须包括备份文件库数据库以及所有物理文件库存档文件。必须在备份存档文件的同时备份数据库,以避免由于不匹配的备份集所导致的任何数据丢失。除非同时备份有数据库和存档,否则在发生故障时将无法恢复库。

    备份内容

    数据库备份

    1. 备份文件库数据库(企业数据库名称)

    2. 备份SOLIDWORKS PDM 主数据库 – ConisioMasterDb

    文档库备份

    3. 备份存档服务器设置

    4. 备份存档文件(物理文件)

    注:请做好以上四个备份,少一个恢复不了,谨记

    数据库备份

    1. 备份文件库数据库

    理想情况下,使用支持活动SQL 数据库备份的专业备份解决方案备份SQL Server 承载的文件库数据库。也可以使用随SQL Server 提供的SQL Management 工具进行备份。

    1. 打开SQL Server Management Studio。

    64715b4201529a5683e9a670367918f8.png

    2. 连接数据库,输入密码

    4f3a60a2374254a03dab413965776cc3.png

    3. 展开数据库文件夹。

    4. 右键单击要备份的数据库(以EPDM数据库为例),然后选择任务> 备份。

    a062d325f825eb61555a6c52fed55ec4.png

    4. 在备份数据库对话框的源下:

    l 对于备份类型,选择完整。

    l 对于备份组件,选择数据库。

    5. 在目标下,单击添加。

    6. 在选择备份目标对话框中,为备份数据库输入目标路径和文件名,然后单击确定。

    7. 单击确定开始备份。

    8. 备份完成后,单击确定。(请勿删除,删除后果自负)

    3b34dc853183f7b2ebc8e67683c05462.png

    9. 对所有其他文件库数据库重复此备份过程。

    10. 退出SQL Server Management Studio。

    2. 备份SolidWorks PDM主数据库

    除了文件库数据库外,还必须备份名为ConisioMasterDb 的SOLIDWORKS PDM 主数据库。

    要备份此数据库,按备份文件库数据库所使用的相同指南进行操作。(请勿删除)

    文档库设置

    3. 备份存档服务器设置

    存档服务器中包含了文件库设置,例如密码和已定义的登录类型。它也是SOLIDWORKS PDM 库存档文件的物理位置。

    备份存档服务器设置时并不备份存档文件。

    备份存档服务器设置后,该备份文件包含在正常文件备份中。

    要备份存档服务器设置:

    1. 在运存档服务器上,在Windows开始菜单打开存档服务器设置。

    bf569694903bcf1289989766c53cbc44.png

    2. 选择工具> 备份设置。

    297580fbe68a56692e4a9e93ec659d4f.png

    3. 在备份设置对话框中:

    l 选择所需要的备份的数据库(这里以EPDM为例,可以备份所有数据库,建议一个一个数据备份)

    l 另外,也可以选择包括所选库和指定将要备份其设置的文件库。

    l 指定或选择备份位置。

    l 默认位置是存档根文件夹。

    l 要安排自动备份的时间,请单击并指定时间计划。

    l 键入并确认备份文件的密码。

    l 还原设置时要求提供此密码。

    l 执行以下操作之一:

    • 若要立即执行备份,请单击启动备份。出现信息确认备份成功时,请单击确定。

    • 要在安排好的时间执行备份,请单击确定。

    cd61a27a5c40f084e60eb1c19e1a98a4.png

    4. 关闭SOLIDWORKS PDM 存档服务器对话框。

    备份文件将保存在指定的位置,名为Backup.dat。(请勿删除,删除后果自负)

    4. 备份存档文件

    文件库存档中包含了存储在文件库中的物理文件。添加到库中的文件存储在由存档服务器指定的存档文件夹中。

    1. 找到与文件库同名的存档文件夹。

    该文件夹存储在存档服务器中已定义的根文件夹路径下。默认路径为C:Program FilesSOLIDWORKS PDMData

    如果不确定存储文件库存档的位置,请查看注册表项HKEY_LOCAL_MACHINESOFTWARESolidWorksApplicationsPDMWorks EnterpriseArchiveServerVaultsvaultnameArchiveTable。

    918fb48c087444f72dd44a3b2a16af9b.png

    2. 通过Windows的复制粘贴命令来备份此文件夹及其内容。把该文件夹的所有文件夹拷贝到备份的存储位置(请勿删除,删除后果自负)

    60f708b9b9003c37249b43c7b041ff71.png

    祝贺你完成SolidWorks EPDM的备份,如有疑问请联系我司,谢谢

    安排数据库备份时间(自动备份数据库)

    设置数据库备份的维护计划(仅限SOLIDWORKS PDM Professional)

    在SQL Server Standard 中设置备份维护计划的最简单的方法是使用SQL 维护向导。

    运行备份维护计划后,该程序将备份文件库数据库并将备份文件放在您指定的文件夹中。这样,正常的日常备份过程中便包含了该备份文件夹。

    设置备份维护计划:

    打开Microsoft SQL Server Management Studio,然后单击连接。

    1. 在左窗格的SQL Server下,展开管理。

    2. 右键单击维护计划,并选择维护计划向导。

    bcebb44e184eac408cd858a27f1b422a.png

    3. SQL Server 维护计划向导单击下一步。

    4. 输入维护计划的名称和说明。

    4a0a1670e3d325ac0e59d13dc2232c41.png

    5. 单击更改以设置时间计划。

    855ee2f3997c6cc051f8826b7d2762c9.png

    6. 在作业计划属性对话框中,指定该计划的名称并选择运行

    7. 数据库备份的重复时间。设置与正常日常文件备份的启动

    8. 时间相近的时间。通常只需几分钟即可将数据库备份到硬

    盘, 单击确定。单击下一步。

    9. 选择计划属性

    1) 选择备份数据库(完整)。

    2d17ce1c6be42be0fbee5b1579ead276.png

    如果您依赖日常备份,也可以选择备份数据库(差异),每周至少应当创建一个完整备份集,单击下一步。

    2) 选择维护任务确保已列出备份任务,单击下一步。

    选择维护任务顺序

    1. 展开数据库列表。

    2. 选择所有用户数据库

    1b0c51411a6e6c133e2b0149b4a409c4.png

    此操作将选择所有SOLIDWORKS PDM 数据库并排除SQL 系统数据库,后者是SOLIDWORKS PDM 所不需要的。

    若要分别选择数据库,请选择这些数据库,然后进行选择。确保选择文件库数据库和ConisioMasterDb数据库。

    7de7be9265639fe50065f4cc5e39e6e5.png

    3. 单击确定。

    4. 选择备份集过期时间,并定义保留现有备份集文件的天数。

    471fda0a725eb7cdb8880b447fac838f.png

    5. 选择备份到磁盘。

    6. 选择为每个数据库创建备份文件。

    7. 对于文件夹,请在SQL Server 上输入指向要创建备份文件的现有文件夹的本地路径。

    256fa3e0873e2fd02b80f3e73ad7e282.png

    8. 单击下一步。

    定义“备份数据库(完整)”任务

    1. 对于备份任务报告,请选择将报告写入文本文件或以电子

    邮件形式发送报告,然后指定保存或发送该报告的位置。

    2. 单击下一步。

    选择报告选项

    完成向导 单击完成。

    维护计划向导进度 当所有任务都完成后,单击关闭。

    3. 退出Microsoft SQL Server Management Studio。

    推荐阅读:

    原来用SOLIDWORKS可以做出这样狂拽炫酷的宇宙 | 操作教程

    SOLIDWORKS强大的配合功能 | 操作技巧

    0d817208aa610e84ee268645d35c57d3.png
    展开全文
  • 本节内容主要包括:概述备份目录管理备份集管理备份信息查看1. 概述管理备份一个重要的目的是删除不再需要的备份,DM7没有提供自动删除过期备份的功能,删除备份需要手动执行。备份管理相关系统过程与函数总结如下:...

    880bb2a446520a88b06ea7277319a63f.png

    下面介绍如何使用DIsql工具管理数据库备份、表空间备份、表备份,以及归档备份。本节内容主要包括:

    1. 概述
    2. 备份目录管理
    3. 备份集管理
    4. 备份信息查看

    1. 概述

    管理备份一个重要的目的是删除不再需要的备份,DM7没有提供自动删除过期备份的功能,删除备份需要手动执行。备份管理相关系统过程与函数总结如下:

    SF_BAKSET_BACKUP_DIR_ADD:添加备份目录。
    SF_BAKSET_BACKUP_DIR_REMOVE:指定删除内存中的备份目录。
    SF_BAKSET_BACKUP_DIR_REMOVE_ALL:删除内存中全部的备份目录。
    SF_BAKSET_CHECK:对备份集进行校验。
    SF_BAKSET_REMOVE:删除指定设备类型和指定备份集目录的备份集。
    SF_BAKSET_REMOVE_BATCH:批量删除满足指定条件的所有备份集。
    SP_DB_BAKSET_REMOVE_BATCH:批量删除指定时间之前的数据库备份集。
    SP_TS_BAKSET_REMOVE_BATCH:批量删除指定表空间对象及指定时间之前的表空间备份集。
    SP_TAB_BAKSET_REMOVE_BATCH:批量删除指定表对象及指定时间之前的表备份集。
    SP_ARCH_BAKSET_REMOVE_BATCH:批量删除指定条件的归档备份集。

    备份管理相关动态视图总结如下:

    V$BACKUPSET:显示备份集基本信息。
    V$BACKUPSET_DBINFO:显示备份集的数据库相关信息。
    V$BACKUPSET_DBF:显示备份集中数据文件的相关信息。
    V$BACKUPSET_ARCH:显示备份集的归档信息。
    V$BACKUPSET_BKP:显示备份集的备份片信息。
    V$BACKUPSET_SEARCH_DIRS:显示备份集搜索目录。
    V$BACKUPSET_TABLE:显示表备份集中备份表信息。
    V$BACKUPSET_SUBS:显示并行备份中生成的子备份集信息。

    SF_BAKSET_BACKUP_DIR_ADD添加备份目录仅对当前会话有效。调用删除备份等函数或查看动态视图时要先调用SF_BAKSET_BACKUP_DIR_ADD添加备份目录,否则仅搜索默认备份路径下的备份集。

    2. 备份目录管理

    这里的备份目录是指备份集搜索目录,这些目录被记录在内存中,当执行动态视图(参见3.2.4.4 备份信息查看)或批量删除备份集时,均会从这些指定目录中先搜索所有备份集信息。

    本节主要内容包括:

    SF_BAKSET_BACKUP_DIR_ADD
     SF_BAKSET_BACKUP_DIR_REMOVE
     SF_BAKSET_BACKUP_DIR_REMOVE_ALL
    SF_BAKSET_BACKUP_DIR_ADD函数

    添加备份目录。若添加目录已经存在或者为库默认备份路径,则认为已经存在,不添加,但也不报错。 定义:

    INT SF_BAKSET_BACKUP_DIR_ADD(
    device_type varchar,
    backup_dir varchar(256)
    )

    参数说明:

    device_type:待添加的备份目录对应存储介质类型,DISK或者TAPE。

    backup_dir:待添加的备份目录。

    返回值:

    1:目录添加成功;其它情况下报错。

    举例说明:

    SQL> select sf_bakset_backup_dir_add('disk','arch_backup_lsn_15092082_15092086');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','arch_backup_lsn_15092082_15092086')
    ---------- --------------------------------------------------------------------
    1          1
    
    used time: 26.411(ms). Execute id is 1569.

    SF_BAKSET_BACKUP_DIR_REMOVE函数

    删除备份目录。若删除目录为库默认备份路径,不进行删除,认为删除失败。若指定目录存在于记录的合法目录中,则删除;不存在或者为空则跳过,正常返回。

    定义:

    INT SF_BAKSET_BACKUP_DIR_REMOVE (
    device_type varchar,
    backup_dir varchar(256)
    )

    参数说明:

    device_type:待删除的备份目录对应存储介质类型。待删除的备份目录对应存储介质类型,DISK或者TAPE。

    backup_dir:待删除的备份目录。

    返回值:

    1:目录删除成功;其他情况报错。

    举例说明:

    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- -----------------------------------
    1          arch_backup_lsn_15092082_15092086
    2          /dm_home/dmdba/dmdbms/data/jydm/bak
    
    used time: 36.620(ms). Execute id is 1573.
    SQL> select sf_bakset_backup_dir_remove('disk','arch_backup_lsn_15092082_15092086');
    
    LINEID     SF_BAKSET_BACKUP_DIR_REMOVE('disk','arch_backup_lsn_15092082_15092086')
    ---------- -----------------------------------------------------------------------
    1          1
    
    used time: 1.057(ms). Execute id is 1575.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- -----------------------------------
    1          /dm_home/dmdba/dmdbms/data/jydm/bak
    
    used time: 0.987(ms). Execute id is 1577.

    SF_BAKSET_BACKUP_DIR_REMOVE_ALL函数清理全部备份目录,默认备份目录除外。

    定义:

    INT SF_BAKSET_BACKUP_DIR_REMOVE_ALL ()

    返回值:

    1:目录全部清理成功;其它情况下报错。

    举例说明:

    SQL> select sf_bakset_backup_dir_remove_all();
    
    LINEID     SF_BAKSET_BACKUP_DIR_REMOVE_ALL()
    ---------- ---------------------------------
    1          1
    
    used time: 1.019(ms). Execute id is 1580.

    3. 备份集管理(备份集校验与删除)

    本节介绍备份管理中最重要的功能,备份集校验和备份集删除。单个备份集删除时并行备份中地子备份集不允许单独删除;在给定备份集搜集目录中发现存在引用删除备份集作为基备份的需要执行级联删除,默认报错。批量删除备份集时,跳过收集到的单独的子备份集。主要内容如下:

    SF_BAKSET_CHECK
     SF_BAKSET_REMOVE
     SF_BAKSET_REMOVE_BATCH
     SP_DB_BAKSET_REMOVE_BATCH
     SP_TS_BAKSET_REMOVE_BATCH
     SP_TAB_BAKSET_REMOVE_BATCH
     SP_ARCH_BAKSET_REMOVE_BATCH

    SF_BAKSET_CHECK函数对备份集进行校验。

    定义:

    INT SF_BAKSET_CHECK(
    device_type varchar,
    
    bakset_pathvarchar(256)
    )

    参数说明:

    device_type:设备类型,disk或tape。

    bakset_path:待校验的备份集目录。

    返回值:

    1:备份集目录存在且合法;否则报错。

    举例说明:

    SQL> backup database full to db_rac_bak_for_check backupset '/dm7/backup/db_rac_bak_for_check';
    executed successfully
    used time: 00:00:01.410. Execute id is 158.
    SQL> select sf_bakset_check('disk','/dm7/backup/db_rac_bak_for_check');
    
    LINEID     SF_BAKSET_CHECK('disk','/dm7/backup/db_rac_bak_for_check')
    ---------- ----------------------------------------------------------
    1          1
    
    used time: 12.669(ms). Execute id is 159.
    
    SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_bak_for_check');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_bak_for_check')
    ---------- -------------------------------------------------------------------
    1          1
    
    used time: 1.610(ms). Execute id is 162.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- --------------------------------
    1          /dm7/backup/db_rac_bak_for_check
    2          +DMDATA/data/rac/bak
    
    used time: 0.770(ms). Execute id is 163.
    SQL> select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME          BACKUP_PATH                      TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- -------------------- -------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        53418202    -1          DB_RAC_BAK_FOR_CHECK /dm7/backup/db_rac_bak_for_check 0           0           1           rac         -1                    2020-05-29 21:14:50.000773        0            0              0           0           33554432    50908                51113                2           4           1            0           0           49398                117507596    0
    
    used time: 00:00:01.023. Execute id is 164.

    SF_BAKSET_REMOVE函数

    删除指定设备类型和指定备份集目录的备份集。一次只检查一个合法.meta文件,然后删除对应备份集;若存在非法或非正常备份的.meta文件,则报错或直接返回,不会接着检查下一个.meta文件;若同一个备份集下还存在其它备份文件或备份集,则只删除备份文件,不会删除整个备份集。

    定义:

    INT SF_BAKSET_REMOVE (
    device_type varchar,
    backsetpath varchar(256),
    option integer
    )

    参数说明:

    device_type:设备类型,disk或tape。

    backsetpath:待删除的备份集目录。

    Option:删除备份集选项,0默认删除,1级联删除。可选参数。并行备份集中子备份集不允许单独删除。目标备份集被其他备份集引用为基备份的,默认删除,报错;级联删除情况下,会递归将相关的增量备份也删除。

    返回值:

    1:备份集目录删除成功,其它情况下报错。

    举例说明:

    SQL> backup database full to db_rac_bak_for_remove backupset '/dm7/backup/db_rac_bak_for_remove';
    executed successfully
    used time: 00:00:01.320. Execute id is 165.
    
    SQL> backup database increment base on backupset '/dm7/backup/db_rac_bak_for_remove' backupset '/dm7/backup/db_rac_bak_for_remove_incr';
    executed successfully
    used time: 00:00:01.255. Execute id is 170.
    
    SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_bak_for_remove');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_bak_for_remove')
    ---------- --------------------------------------------------------------------
    1          1
    
    used time: 1.836(ms). Execute id is 171.
    SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_bak_for_remove_incr');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_bak_for_remove_incr')
    ---------- -------------------------------------------------------------------------
    1          1
    
    used time: 1.444(ms). Execute id is 172.
    SQL> select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME                        BACKUP_PATH                            TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME             BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- ---------------------------------- -------------------------------------- ----------- ----------- ----------- ----------- ----------- --------------------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        53418202    -1          DB_RAC_BAK_FOR_CHECK               /dm7/backup/db_rac_bak_for_check       0           0           1           rac         -1                                2020-05-29 21:14:50.000773        0            0              0           0           33554432    50908                51113                2           4           1            0           0           49398                117507596    0
    2          DISK        1763138770  -1          DB_RAC_BAK_FOR_REMOVE              /dm7/backup/db_rac_bak_for_remove      0           0           1           rac         -1                                2020-05-29 22:00:34.000524        0            0              0           0           33554432    50908                51119                2           4           1            0           0           49398                117507596    0
    3          DISK        -1036285990 -1          DB_INCR_rac_20200529_220232_000624 /dm7/backup/db_rac_bak_for_remove_incr 1           0           1           rac         -1          DB_RAC_BAK_FOR_REMOVE 2020-05-29 22:02:33.000834        0            0              0           0           33554432    50908                51135                2           4           1            0           0           49398                117507596    0
    
    used time: 00:00:01.038. Execute id is 173.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- --------------------------------------
    1          /dm7/backup/db_rac_bak_for_check
    2          /dm7/backup/db_rac_bak_for_remove
    3          /dm7/backup/db_rac_bak_for_remove_incr
    4          +DMDATA/data/rac/bak
    
    used time: 0.781(ms). Execute id is 174.
    
    SQL> select sf_bakset_remove('disk','/dm7/backup/db_rac_bak_for_remove');
    select sf_bakset_remove('disk','/dm7/backup/db_rac_bak_for_remove');
    [-8202]:Be the base backupset of /dm7/backup/db_rac_bak_for_remove_incr,cannot be removed.
    used time: 00:00:01.023. Execute id is 0.

    报错了,提示说它是另一个备份集的基备份不能被删除

    SQL> select sf_bakset_remove('disk','/dm7/backup/db_rac_bak_for_remove',1);
    
    LINEID     SF_BAKSET_REMOVE('disk','/dm7/backup/db_rac_bak_for_remove',1)
    ---------- --------------------------------------------------------------
    1          1
    
    used time: 50.201(ms). Execute id is 176.

    检查备份集可以确认在删除基备份时确实级联删除了增量备份

    SQL> select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME          BACKUP_PATH                      TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- -------------------- -------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        53418202    -1          DB_RAC_BAK_FOR_CHECK /dm7/backup/db_rac_bak_for_check 0           0           1           rac         -1                    2020-05-29 21:14:50.000773        0            0              0           0           33554432    50908                51113                2           4           1            0           0           49398                117507596    0
    
    used time: 00:00:01.050. Execute id is 177.

    SF_BAKSET_REMOVE_BATCH函数

    批量删除满足指定条件的所有备份集。

    定义:

    INT SF_BAKSET_REMOVE_BATCH (
    device_type varchar,
    end_time datetime,
    range int,
    obj_name varchar(257)
    )

    参数说明:

    device_type:设备类型,disk或tape。指定NULL,则忽略存储设备的区分。

    end_time:删除备份集生成的结束时间,仅删除end_time之前的备份集,必须指定。

    range:指定删除备份的级别。1代表库级,2代表表空间级,3代表表级,4代表归档备份。若指定NULL,则忽略备份集备份级别的区分。

    obj_name:待删除备份集中备份对象的名称,仅表空间级和表级有效。若为表级备份删除,则需指定完整的表名(模式.表名),否则,将认为删除会话当前模式下的表备份。若指定为NULL,则忽略备份集中备份对象名称区分

    返回值:

    1:备份集目录删除成功,其它情况下报错。

    举例说明:

    SQL> backup database full to db_rac_full_bak_for_remove backupset '/dm7/backup/db_rac_full_bak_for_remove';
    executed successfully
    used time: 00:00:01.498. Execute id is 184.
    SQL> backup tablespace main full to tab_main_full_bak_for_remove backupset '/dm7/backup/tab_main_full_bak_for_remove';
    executed successfully
    used time: 00:00:01.121. Execute id is 185.
    SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_full_bak_for_remove');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_full_bak_for_remove')
    ---------- -------------------------------------------------------------------------
    1          1
    
    used time: 1.574(ms). Execute id is 186.
    SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/tab_main_full_bak_for_remove');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/tab_main_full_bak_for_remove')
    ---------- ---------------------------------------------------------------------------
    1          1
    
    used time: 1.881(ms). Execute id is 187.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- ----------------------------------------
    1          /dm7/backup/db_rac_full_bak_for_remove
    2          /dm7/backup/tab_main_full_bak_for_remove
    3          +DMDATA/data/rac/bak
    
    used time: 0.784(ms). Execute id is 188.
    SQL>  select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME                  BACKUP_PATH                              TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- ---------------------------- ---------------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        760083173   -1          DB_RAC_FULL_BAK_FOR_REMOVE   /dm7/backup/db_rac_full_bak_for_remove   0           0           1           rac         -1                    2020-05-30 10:21:23.000661        0            0              0           0           33554432    50908                51141                2           4           1            0           0           49398                117507596    0
    2          DISK        -1117064059 -1          TAB_MAIN_FULL_BAK_FOR_REMOVE /dm7/backup/tab_main_full_bak_for_remove 0           0           2           MAIN        4                     2020-05-30 10:22:41.000744        0            0              0           0           33554432    50908                51147                1           1           1            0           0           49398                117507596    0
    
    used time: 00:00:01.025. Execute id is 189.
    
    
    SQL> select sf_bakset_remove_batch('disk',now(),null,null);
    
    LINEID     SF_BAKSET_REMOVE_BATCH('disk',NOW(),NULL,NULL)
    ---------- ----------------------------------------------
    1          1
    
    used time: 21.228(ms). Execute id is 190.
    SQL> select * from v$backupset;
    no rows
    
    used time: 00:00:01.023. Execute id is 191.

    SP_DB_BAKSET_REMOVE_BATCH过程批量删除指定时间之前的数据库备份集。使用该方法前,需要先使用SF_BAKSET_BACKUP_DIR_ADD添加将要删除的备份集目录,否则只删除默认备份路径下的备份集。

    定义:

    SP_DB_BAKSET_REMOVE_BATCH (
    device_type varchar,
    end_time datetime
    )

    参数说明:

    device_type:设备类型,disk或tape。指定NULL,则忽略存储设备的区分。

    end_time:删除备份集生成的结束时间,仅删除end_time之前的备份集,必须指定。

    举例说明:

    SQL> backup database full to db_rac_full_bak_for_del backupset '/dm7/backup/db_rac_full_bak_for_del';
    executed successfully
    used time: 00:00:01.580. Execute id is 194.
    SQL> select sf_bakset_backup_dir_add('disk','/dm7/backup/db_rac_full_bak_for_del');
    
    LINEID     SF_BAKSET_BACKUP_DIR_ADD('disk','/dm7/backup/db_rac_full_bak_for_del')
    ---------- ----------------------------------------------------------------------
    1          1
    
    used time: 1.725(ms). Execute id is 195.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- -----------------------------------
    1          /dm7/backup/db_rac_full_bak_for_del
    2          +DMDATA/data/rac/bak
    
    used time: 0.483(ms). Execute id is 196.
    SQL> select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME             BACKUP_PATH                         TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- ----------------------- ----------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        361744824   -1          DB_RAC_FULL_BAK_FOR_DEL /dm7/backup/db_rac_full_bak_for_del 0           0           1           rac         -1                    2020-05-30 10:27:00.000621        0            0              0           0           33554432    50908                51153                2           4           1            0           0           49398                117507596    0
    
    used time: 00:00:01.024. Execute id is 197.
    SQL> call sp_db_bakset_remove_batch('disk',now());
    DMSQL executed successfully
    used time: 36.535(ms). Execute id is 198.
    SQL> select * from v$backupset;
    no rows
    
    used time: 00:00:01.021. Execute id is 199.

    SP_TS_BAKSET_REMOVE_BATCH过程批量删除指定表空间对象及指定时间之前的表空间备份集。使用该方法前,需要先使用SF_BAKSET_BACKUP_DIR_ADD添加将要删除的备份集目录,否则只删除默认备份路径下的备份集。

    定义:

    SP_TS_BAKSET_REMOVE_BATCH (
    device_type varchar,
    end_time datetime,
    ts_name varchar(128)
    )

    参数说明:

    device_type:设备类型,disk或tape。指定NULL,则忽略存储设备的区分。

    end_time:删除备份集生成的结束时间,仅删除end_time之前的备份集,必须指定。

    ts_name:表空间名,若未指定,则认为删除所有满足条件的表空间备份集。

    举例说明:

    SQL> backup tablespace main full to tab_main_bak_full_for_del backupset '/dm7/backup/tab_main_bak_full_for_del';
    executed successfully
    used time: 00:00:01.123. Execute id is 202.
    SQL> sf_bakset_backup_dir_add('disk','/dm7/backup/tab_main_bak_full_for_del');
    DMSQL executed successfully
    used time: 1.256(ms). Execute id is 203.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- -------------------------------------
    1          /dm7/backup/tab_main_bak_full_for_del
    2          +DMDATA/data/rac/bak
    
    used time: 0.773(ms). Execute id is 204.
    SQL> select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME               BACKUP_PATH                           TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- ------------------------- ------------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        798489856   -1          TAB_MAIN_BAK_FULL_FOR_DEL /dm7/backup/tab_main_bak_full_for_del 0           0           2           MAIN        4                     2020-05-30 10:38:29.000350        0            0              0           0           33554432    50908                51159                1           1           1            0           0           49398                117507596    0
    
    used time: 00:00:01.027. Execute id is 205.
    SQL> call sp_ts_bakset_remove_batch('disk',now(),'main');
    DMSQL executed successfully
    used time: 16.765(ms). Execute id is 206.
    SQL> select * from v$backupset;
    
    LINEID     DEVICE_TYPE BACKUP_ID   PARENT_ID   BACKUP_NAME               BACKUP_PATH                           TYPE        LEVEL       RANGE#      OBJECT_NAME OBJECT_ID   BASE_NAME BACKUP_TIME                 DESC# ENCRYPT_TYPE COMPRESS_LEVEL WITHOUT_LOG USE_PWR     PKG_SIZE    BEGIN_LSN            END_LSN              BKP_NUM     DBF_NUM     PARALLEL_NUM DDL_CLONE   MPP_FLAG    MIN_TRX_START_LSN    MIN_EXEC_VER CUMULATIVE
    ---------- ----------- ----------- ----------- ------------------------- ------------------------------------- ----------- ----------- ----------- ----------- ----------- --------- --------------------------- ----- ------------ -------------- ----------- ----------- ----------- -------------------- -------------------- ----------- ----------- ------------ ----------- ----------- -------------------- ------------ -----------
    1          DISK        798489856   -1          TAB_MAIN_BAK_FULL_FOR_DEL /dm7/backup/tab_main_bak_full_for_del 0           0           2           MAIN        4                     2020-05-30 10:38:29.000350        0            0              0           0           33554432    50908                51159                1           1           1            0           0           49398                117507596    0
    
    used time: 00:00:01.022. Execute id is 207.

    说明指定表空间名时表空间名要大写

    SQL> call sp_ts_bakset_remove_batch('disk',now(),'MAIN');
    DMSQL executed successfully
    used time: 13.667(ms). Execute id is 208.
    SQL> select * from v$backupset;
    no rows
    
    used time: 00:00:01.023. Execute id is 209.

    删除备份目录

    SQL> sf_bakset_backup_dir_remove_all();
    DMSQL executed successfully
    used time: 0.787(ms). Execute id is 210.
    SQL> select * from v$backupset_search_dirs;
    
    LINEID     DIR
    ---------- --------------------
    1          +DMDATA/data/rac/bak
    
    used time: 0.836(ms). Execute id is 211.

    SP_TAB_BAKSET_REMOVE_BATCH过程批量删除指定表对象及指定时间之前的表备份集。使用该方法前,需要先使用SF_BAKSET_BACKUP_DIR_ADD添加将要删除的备份集目录,否则只删除默认备份路径下的备份集。

    定义:

    SP_TAB_BAKSET_REMOVE_BATCH (
    device_type varchar,
    end_time datetime,
    sch_name varchar(128),
    tab_name varchar(128)
    )

    ...

    ✨ 接下来内容请点击【原文】进行查看~

    更多数据库相关内容,可访问【墨天轮】进行浏览。

    a3193fe69c8a9a8daaf6db6b707c832d.png
    展开全文
  • Ucache备份技术:采用首次完备加永久增量备份为避免因自然灾害等意外情况而导致的本地数据丢失情况,异地数据容灾也是企业数据保护的一大常见命题。Ucahe备份呢支持通过远程复制技术,将本地数据同步到异地,实现异地...
  • Ucahe备份呢支持通过远程复制技术,将本地数据同步到异地,实现异地数据保护。一站式的web管理,支持增量 ,差异,永久,定时,多副本等30多项功能列表,8项灾备技术,3款产品,满足企业不同场景的数据备份需求,帮助企业...
  • 本文主要介绍了 Redis 持久化的两种机制:RDB 和 AOF,以及键过期的策略:惰性删除和定期删除,还有 RDB、AOF 和复制功能对过期键的处理。RDBRDB 是 Redis 持久化的第一种方式。有两个 Redis 命令可以用于生成 RDB ...
  • 背景学习一款数据库,要学会备份和恢复。备份是一个严谨的工作,作为一个dba,掌握数据库备份、恢复的各种手段。下面让我们一起来看看TiDB的备份恢复有那些手段吧。...(key-versionT(SO全局唯一递增时间...
  • MongoDB现有备份恢复方案:1. mongodump/mongorestore(BSON)2. mongoexport/mongoimport(JSON,CSV)3. MongoDB cloud service Atlas(incremental backup/snapshot)4. Filesystem Snapshots(lvm,Amazon’s EBS ...
  • 0 前言原计划国庆节更新一...1 现状分析1.1 数据库现状数据类型数据种类:基础地理空间框架、调查评价、国土空间规划、管理审批、招商管理、建设管理等类型数据存储类型:以要素(FeatureClass)和数据(FeatureDa...
  • 在达梦读写分离系统中,当主机...这种情况下,我们可以使用BAT脚本进行定期完全备份,增量备份数据库以及删除不用的备份集。首先在数据库中创建备份用的存储过程PRO_BackupDatabasecreate or replace PROCEDURE PRO...
  • 朋友们,我们在使用数据库时,可能精力都放在了数据库本身的各种业务处理,往往忽视了对数据库的定期备份。有些朋友想起来就随手备份一下,忘记了也就忘记了,等到需要历史备份的时候,我们才发现手头什么也没有。...
  • Ucache备份技术:采用首次完备加永久增量备份为避免因自然灾害等意外情况而导致的本地数据丢失情况,异地数据容灾也是企业数据保护的一大常见命题。Ucahe备份呢支持通过远程复制技术,将本地数据同步到异地,实现异地...
  • Oracle备份面临的挑战在传统企业里,经常会用Oracle数据库去承载业务重要核心数据,同时Oracle针对不同的恢复场景提供了灵活多样的恢复操作方法,灵活的设计给备份和恢复带来了更多的复杂性,因此Oracle的备份管理...
  • 擅长 MySQL、PostgreSQL、MongoDB 等开源数据库相关的备份恢复、SQL 调优、监控运维、高可用架构设计等。目前任职于爱可生,为各大运营商及银行金融企业提供 MySQL 相关技术支持、MySQL 相关课程培训等工作。本文...
  • 维护过数据库的同学应该都能体会,数据备份对于数据库来说可以说至关重要,尤其是关键业务。TiDB 原生的备份恢复方案已经在多家客户得到稳定运行的验证,但是对于业务量巨大的系统存在如下几个痛点:集群中...
  • 近些年,数据安全事件频发。作为企业的核心资产,数据的外泄、破坏都会导致不可挽回的经济...我们会优先考虑数据库备份集的容灾设计:两地三中心VS混合云、权限分配&监控告警&恢复演练。IDC混合云场景下的备...
  • 本文主要介绍了 Redis 持久化的两种机制:RDB 和 AOF,以及键过期的策略:惰性删除和定期删除,还有 RDB、AOF 和复制功能对过期键的处理。RDBRDB 是 Redis 持久化的第一种方式。有两个 Redis 命令可以用于生成 RDB ...
  • 很多时候,我们想找微信群里好友比较久之前分享的照片,结果往往会出现这一幕:“图片已过期或已被清理”。这句让人崩溃的提醒,让我们无数次懊悔,怎么不及时保存这些重要的图片。如今,腾讯官方推出了一款叫「群...
  • 英语习语quality timequality time嗨,...而time是“时间”的含义。那quality time是什么意思呢?含义quality time的意思是“time that you spend with someone, giving them your full attention because you valu...
  • 在最新更新的泽塔奥特曼18的剧情当中,主要描述的对象是之前泽塔得到的强大武器贝利亚的黄昏。贝利亚的黄昏是一把有自己独立意识的超级强大武器,威力要比麦克斯奥特曼当中的彩虹刀更胜一筹,可以说是目前为止出现...
  • TM“商标注册时间要多长时间?今天诚优就为大家介绍一下这个TM商标的相关事项。“TM”是英语中“trademark”的缩写,在中文中意为“商业标记”。因此,“TM”表示“商标”。其功能是告诉人们其标记的图像或文字是...
  • 近日,相信大家都还经常在网上会看到“一起去爬山吗”这句话,很多人都不知道是怎么回事呢?这是个什么梗呢?这个梗背后的意思是什么呢?一起来看一下。一起去爬山是出自哪部电视剧一起去爬山是来自于最近特别火的网...
  • 展开全部无论做什么事情,不要2113推脱说没有时间,只5261要真心愿意去做,时间总是有的,4102并且充裕1653到足够完成所要做的事情。当然时间也需要珍惜。鲁迅的成功,有一个重要的秘诀,就是珍惜时间。鲁迅十二岁在...
  • 启用定时备份后,数据库运行一长,必然会积累很多的备份文件,占用大量存储空间,然而时间久远的备份文件可能已经失效,不再具有保留的意义。对于占用存储空间又没有保留意义的文件,当然是清理掉比较好。 清理这种...
  • 该方式优点:快速通过mongodump初始化数据库,大大减少新的secondary节点从头开始初始化的风险:网络壅塞、oplog.rs过期、耗时太长等。 还原的关键:一致性mongodump备份 + local.oplog.rs包含备份完成时的最后时点...
  • 该方式优点:快速通过mongodump初始化数据库,大大减少新的secondary节点从头开始初始化的风险:网络壅塞、oplog.rs过期、耗时太长等。 还原的关键:一致性mongodump备份 + local.oplog.rs包含备份完成时的最后时点...

空空如也

空空如也

1 2 3 4
收藏数 68
精华内容 27
关键字:

备份集过期时间