达梦7数据库增量备份恢复

操作系统 Redhat 6.10

达梦V7.6.0.197-Build(2019.09.12-112648)ENT

本文通过backup database SQL语句对达梦数据库进行增量备份

然后通过dmrestore命令恢复增量数据库

前提条件

数据库要处于归档模式

SQL> select arch_name,arch_type,arch_dest from v$dm_arch_ini;

行号     ARCH_NAME      ARCH_TYPE ARCH_DEST
---------- -------------- --------- ---------
1          ARCHIVE_LOCAL1 LOCAL     /dm7/arch

已用时间: 4.194(毫秒). 执行号:13.
SQL> select arch_mode from v$database;

行号     ARCH_MODE
---------- ---------
1          Y

已用时间: 1.007(毫秒). 执行号:14.
SQL>

执行命令如下:
1.全备份

disql sysdba/SYSDBA

backup database full backupset '/dm7/backup/full_bak';

2.增量备份

disql sysdba/SYSDBA

insert into test values(1);
commit;
select checkpoint(1);
backup database increment with backupdir '/dm7/backup/' to dmincord1  bakfile '/dm7/backup/dmincord1.bak'  backupinfo '测试增量备份1' ;

3.恢复增量备份

退出disql,使用dmrestore工具执行恢复
dmrestore ini_path=/dm7/data/DAMENG/dm.ini file=/dm7/backup/dmincord1.bak

4.检查增量数据

disql sysdba/SYSDBA

select * from test;

执行过程如下

SQL> create table test ( a int );
操作已执行
已用时间: 4.477(毫秒). 执行号:4.
SQL> backup database full backupset '/dm7/backup/full_bak';
操作已执行
已用时间: 00:00:01.211. 执行号:5.
SQL> --增量备份
insert into test values(1);
影响行数 1

已用时间: 0.580(毫秒). 执行号:6.
SQL> commit;
操作已执行
已用时间: 1.168(毫秒). 执行号:7.
SQL> select checkpoint(1);

行号     CHECKPOINT(1)
---------- -------------
1          0

已用时间: 146.546(毫秒). 执行号:8.
SQL> backup database increment with backupdir '/dm7/backup/' to dmincord1  bakfile '/dm7/backup/dmincord1.bak'  backupinfo '测试增量备份1' ;
操作已执行
已用时间: 00:00:01.603. 执行号:10.
SQL> host ls -l /dm7/backup/
total 8
drwxr-xr-x. 2 dmdba dinstall 4096 Jun  7 19:40 full_bak
drwxr-xr-x. 2 dmdba dinstall 4096 Jun  7 19:41 incr_bak

SQL> exit

启动达梦console工具,

$DM_HOME/tools/console

在Backup and Restore设置好Search Directory(S),点击Refresh Backup(R)

可观察到增量备份和全备份的信息达梦7数据库增量备份恢复_第1张图片


[dmdba@dm7 bin]$ /etc/rc.d/init.d/DmServiceDMSERVER stop
Stopping DmServiceDMSERVER:                                [ OK ]
[dmdba@dm7 bin]$  dmrestore ini_path=/dm7/data/DAMENG/dm.ini file=/dm7/backup/dmincord1.bak
restore V7.6.0.197-Build(2019.09.12-112648)ENT
file dm.key not found, use default license!


backup sig:            BA
backup tool version:   12595
backup db name:        DAMENG
backup db magic:       -624002858
backup pemnt magic:    -2035944448
backup name:           DMINCORD1
backup type:           increment
backup level:          online
backup range:          database
backup description:    测试增量备份1
compressed level:      0
encrypt_type:          0
encrypt_id:            2052
rac node:              0
page check:            0
rlog encrypt:          0
external cipher id:    0
external hash id:      0
length in char:        0
use new hash:          1
backup time:           2020-06-07 19:20:51
page size:             8 KB
extent size:           16
case sensitive:        1
log page size:         512 B
charset:               0
data version:          0x7000A
sys version:           V7.1.6.197-Build(2019.09.12-112648)ENT
enable policy:         0
mpp_timestamp:         1591528850
crc_check:             TRUE
parallel type:         0
parallel info len:     0
backup db fil num:     10
archive flag:          1
base backup LSN:       77088
base name:             DMINCORD1
backup with log:       Yes
before backup LSN:     86337
after backup LSN:      86337


$bak_seq |$file_path                                        |$size(K)       |$used(K)
        1|/dm7/backup/dmincord1.bak                         |       65536.00|       35062.00


$file_seq |$type|$ts_name       |$state    |$size(K)  |$seq_in_bak    |$off_in_bak(B) |$len_in_bak(B) |$file_path                                        |$mirror_path
         1|DBF  |SYSTEM         |ONLINE    |     22528|              1|          47104|         122880|/dm7/data/DAMENG/SYSTEM.DBF                       |
         2|DBF  |ROLL           |ONLINE    |   2048000|              1|         169984|       35700736|/dm7/data/DAMENG/ROLL.DBF                         |
         3|DBF  |MAIN           |ONLINE    |    131072|              1|       35870720|          32768|/dm7/data/DAMENG/MAIN.DBF                         |
         4|DBF  |BOOKSHOP       |ONLINE    |    153600|              1|       35903488|              0|/dm7/data/DAMENG/BOOKSHOP.DBF                     |
         5|DBF  |DMHR           |ONLINE    |    131072|              1|       35903488|              0|/dm7/data/DAMENG/DMHR.DBF                         |
         6|DBF  |TBS3           |ONLINE    |     32768|              1|       35903488|              0|/dm7/disk1/tbs3_1.dbf                             |
         7|DBF  |TBS3           |ONLINE    |     32768|              1|       35903488|              0|/dm7/disk2/tbs3_2.dbf                             |
         8|DBF  |TBS3           |ONLINE    |     36864|              1|       35903488|              0|/dm7/data/tbs3_3.dbf                              |
         9|DBF  |TEST           |ONLINE    |     32768|              1|       35903488|              0|/dm7/data/DAMENG/test.dbf                         |
        10|LOG  |ARCHLOG        |ONLINE    |         0|              1|       35903488|              0|                                                  |

Continue?[Y/N]:y
restore bak_file: /dm7/backup/inc/dmfull1.bak ...
start restore database...
start restore file: /dm7/data/DAMENG/SYSTEM.DBF(SYSTEM), pages: 688
end restore file: /dm7/data/DAMENG/SYSTEM.DBF(SYSTEM)
start restore file: /dm7/data/DAMENG/ROLL.DBF(ROLL), pages: 4390
end restore file: /dm7/data/DAMENG/ROLL.DBF(ROLL)
start restore file: /dm7/data/DAMENG/MAIN.DBF(MAIN), pages: 4
end restore file: /dm7/data/DAMENG/MAIN.DBF(MAIN)
start restore file: /dm7/data/DAMENG/BOOKSHOP.DBF(BOOKSHOP), pages: 108
end restore file: /dm7/data/DAMENG/BOOKSHOP.DBF(BOOKSHOP)
start restore file: /dm7/data/DAMENG/DMHR.DBF(DMHR), pages: 85
end restore file: /dm7/data/DAMENG/DMHR.DBF(DMHR)
start restore file: /dm7/data/DAMENG/tbs3_1.dbf(TBS3), pages: 4
end restore file: /dm7/data/DAMENG/tbs3_1.dbf(TBS3)
start restore file: /dm7/data/DAMENG/tbs3_2.dbf(TBS3), pages: 1
end restore file: /dm7/data/DAMENG/tbs3_2.dbf(TBS3)
start restore file: /dm7/data/DAMENG/tbs3_3.dbf(TBS3), pages: 1
end restore file: /dm7/data/DAMENG/tbs3_3.dbf(TBS3)
start restore file: /dm7/data/DAMENG/test.dbf(TEST), pages: 2
end restore file: /dm7/data/DAMENG/test.dbf(TEST)
end restore database data files.

restore bak_file: /dm7/backup/inc1.bak ...
start restore database...
end restore database data files.

restore bak_file: /dm7/backup/dmincord1.bak ...
start restore database...
start restore file: /dm7/data/DAMENG/SYSTEM.DBF(SYSTEM), pages: 15
end restore file: /dm7/data/DAMENG/SYSTEM.DBF(SYSTEM)
start restore file: /dm7/data/DAMENG/ROLL.DBF(ROLL), pages: 4358
end restore file: /dm7/data/DAMENG/ROLL.DBF(ROLL)
start restore file: /dm7/data/DAMENG/MAIN.DBF(MAIN), pages: 4
end restore file: /dm7/data/DAMENG/MAIN.DBF(MAIN)
end restore database data files.

Apply archive log LSN from 86338 to 86337, time used:0.000s.
restore finished, code = 0!

restore successfully!
restore time used: 4840.037(ms)
[dmdba@dm7 bin]$
[dmdba@dm7 bin]$ /etc/rc.d/init.d/DmServiceDMSERVER start
Starting DmServiceDMSERVER:                                [ OK ]
[dmdba@dm7 bin]$ disql sysdba/SYSDBA

服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间: 6.840(毫秒)
disql V7.6.0.197-Build(2019.09.12-112648)ENT
SQL> select * from test;

行号     A
---------- -----------
1          1

已用时间: 2.859(毫秒). 执行号:12.
SQL>

可以看到全备份后插入的数据已经恢复。

参考文档

达梦(7)增量备份恢复测试

https://blog.csdn.net/xcl168/article/details/18353201

你可能感兴趣的:(达梦7数据库增量备份恢复)