KingbaseES V8R6备份恢复案例之---手工清理冗余历史备份
案例说明:
对于KingbaseES V8R6的通过sys_rman执行的物理历史备份,可以在执行备份时,备份的保留(retention)策略自动清理。不能通过手工删除备份,可以通过expire参数手工清理历史的冗余备份。
适用版本:
KingbaseES V8R6
一、查看历史备份
1、查看备份信息
[kingbase@node101 bin]$ /opt/Kingbase/ES/V8R6_041/Server/bin/sys_rman --config=/home/kingbase/kbbr1_repo/sys_rman.conf --stanza=kingbase info
stanza: kingbase
status: ok
cipher: none
db (current)
wal archive min/max (V008R006C005B0041): 00000001000000000000005B/00000001000000000000007A
full backup: 20220628-152624F
timestamp start/stop: 2022-06-28 15:26:24 / 2022-06-28 15:27:55
wal start/stop: 00000001000000000000005B / 00000001000000000000005B
database size: 717.3MB, database backup size: 717.3MB
repo1: backup set size: 96.0MB, backup size: 96.0MB
full backup: 20220628-153858F
timestamp start/stop: 2022-06-28 15:38:58 / 2022-06-28 15:39:30
wal start/stop: 00000001000000000000005D / 00000001000000000000005D
database size: 717.3MB, database backup size: 717.3MB
repo1: backup set size: 96.0MB, backup size: 96.0MB
full backup: 20220628-154330F
timestamp start/stop: 2022-06-28 15:43:30 / 2022-06-28 15:46:41
wal start/stop: 000000010000000000000063 / 000000010000000000000063
database size: 717.4MB, database backup size: 717.4MB
repo1: backup set size: 96.0MB, backup size: 96.0MB
full backup: 20220628-155008F
timestamp start/stop: 2022-06-28 15:50:08 / 2022-06-28 15:50:39
wal start/stop: 000000010000000000000065 / 000000010000000000000065
database size: 717.4MB, database backup size: 717.4MB
repo1: backup set size: 96.0MB, backup size: 96.0MB
full backup: 20220628-155134F
timestamp start/stop: 2022-06-28 15:51:34 / 2022-06-28 15:54:46
wal start/stop: 00000001000000000000006B / 00000001000000000000006B
database size: 759.6MB, database backup size: 759.6MB
repo1: backup set size: 103.9MB, backup size: 103.9MB
# 如上所示,对于full类型的历史备份,目前有5个。
2、查看备份配置文件
[kingbase@node101 bin]$ cat ~/kbbr1_repo/sys_rman.conf
# Genarate by script at 20220613174915, should not change manually
[kingbase]
kb1-path=/data/kingbase/v8r6_041/data
kb1-port=54325
kb1-user=system
[global]
repo1-path=/home/kingbase/kbbr1_repo
repo1-retention-full=5 ##冗余备份的retention是5
log-path=/opt/Kingbase/ES/V8R6_041/Server/log
log-level-file=info
log-level-console=info
log-subprocess=y
process-max=4
#### default gz, support: gz none
compress-type=gz
compress-level=3
band-width=0
二、清理冗余历史备份
1、修改sys_rman.conf
2、执行清理
[kingbase@node101 bin]$ /opt/Kingbase/ES/V8R6_041/Server/bin/sys_rman --config=/home/kingbase/kbbr1_repo/sys_rman.conf --stanza=kingbase expire
2022-06-29 17:23:17.622 P00 INFO: expire command begin 2.27: --config=/home/kingbase/kbbr1_repo/sys_rman.conf --exec-id=6425-f3c5cce3 --log-level-console=info --log-level-file=info --log-path=/opt/Kingbase/ES/V8R6_041/Server/log --repo1-path=/home/kingbase/kbbr1_repo --repo1-retention-full=1 --stanza=kingbase
2022-06-29 17:23:17.623 P00 INFO: repo1: expire full backup 20220628-152624F
2022-06-29 17:23:17.623 P00 INFO: repo1: expire full backup 20220628-153858F
2022-06-29 17:23:17.623 P00 INFO: repo1: expire full backup 20220628-154330F
2022-06-29 17:23:17.623 P00 INFO: repo1: expire full backup 20220628-155008F
2022-06-29 17:23:17.629 P00 INFO: repo1: remove expired backup 20220628-155008F
2022-06-29 17:23:17.683 P00 INFO: repo1: remove expired backup 20220628-154330F
2022-06-29 17:23:17.791 P00 INFO: repo1: remove expired backup 20220628-153858F
2022-06-29 17:23:17.878 P00 INFO: repo1: remove expired backup 20220628-152624F
2022-06-29 17:23:17.951 P00 INFO: repo1: 12-1 remove archive, start = 00000001000000000000005B, stop = 00000001000000000000006A
2022-06-29 17:23:17.951 P00 INFO: expire command end: completed successfully (331ms)
3、查看备份信息
[kingbase@node101 bin]$ /opt/Kingbase/ES/V8R6_041/Server/bin/sys_rman --config=/home/kingbase/kbbr1_repo/sys_rman.conf --stanza=kingbase info
stanza: kingbase
status: ok
cipher: none
db (current)
wal archive min/max (V008R006C005B0041): 00000001000000000000006B/00000001000000000000007A
full backup: 20220628-155134F
timestamp start/stop: 2022-06-28 15:51:34 / 2022-06-28 15:54:46
wal start/stop: 00000001000000000000006B / 00000001000000000000006B
database size: 759.6MB, database backup size: 759.6MB
repo1: backup set size: 103.9MB, backup size: 103.9MB
# 如上所示,清理后,只留了最近的full的备份。
KINGBASE研究院