GaussDB T 备份工具 Roach 备份数据库
关于GaussDB T 的备份官方推荐了两种方案,一种是使用华为的数据管理平台Database Manager,一种是直接使用工具Roach。
使用Database Manager有图形化管理页面,只需点击即可备份,通过调用roach工具完成,不过需要另外安装一套DM,或者是与其他系统共用。
使用工具Roach直接在服务上备份,该通过物理文件拷贝的方式对数据库进行备份。
本文介绍使用GaussRoach工具完成对数据的备份,增量备份,查看备份、删除备份等内容。
1、安装备份工具Roach
roach是单独的安装包,直接解压即可运行,不过需要设置环境变量,不然会报错,参考:《GaussDB T 备份工具GaussRoach.py 报错:NoneType object has no attribute endswith》https://www.modb.pro/db/13863
[omm@pr7 roach]$ export GAUSSHOME=/opt/gaussdb/app [omm@pr7 roach]$ export ROACH_HOME=/opt/software/roach [omm@pr7 roach]$ export GAUSSLOG=/opt/software/roach/log[omm@pr7 roach]$ python GaussRoach.py -h GaussRoach.py is a utility to backup GaussDB100 to NBU/disk and restore GaussDB100 from NBU/disk. Usage: python GaussRoach.py -h | --help python GaussRoach.py -v | --version python GaussRoach.py -t start python GaussRoach.py -t backup [options] python GaussRoach.py -t restore [options] python GaussRoach.py -t stop python GaussRoach.py -t delete [options] python GaussRoach.py -t show [options] python GaussRoach.py -t validate [options]
创建相关的目录
mkdir -p /opt/gaussdb/media mkdir -p /opt/gaussdb/meta
2、全备数据库
直接运行GaussRoach.py配置,–mode指定是单实例还是集群,-t backup指定备份操作,–media-destination指定介质存放目录,–metadata-destination指定元数控存在目录。
[omm@pr7 roach]$ python GaussRoach.py --mode single -t backup --media-destination /opt/gaussdb/media --metadata-destination /opt/gaussdb/meta start run backup. Successfully backup data, backup key: 20200119_163640, 00:00:20 Performing backup completed.
查看备份
[omm@pr7 roach]$ python GaussRoach.py --mode single -t show --all-backups --metadata-destination /opt/gaussdb/meta start run show. | BACKUP KEY |BKP TYPE|MEDIA | START TIME | END TIME | BKP SIZE | STATUS | |===============|========|======|===================|===================|============|===========| |20200119_163640| FULL | DISK |2020-01-19 16:36:40|2020-01-19 16:37:00| 527.2 MB | SUCCESS | Performing show completed.
查看备份文件
[root@pr7 gaussdb]# tree me*media └── roach ├── 20200119_163640 ├── data │ ├── arch_3_0.bak │ ├── backupset │ ├── ctrl_0_0.bak │ ├── data_SYSAUX_12_0.bak │ ├── data_SYSTEM_0_0.bak │ ├── data_TEMP_1_0.bak │ ├── data_TEMP2_9_0.bak │ ├── data_TEMP2_UNDO_11_0.bak │ ├── data_UNDO_3_0.bak │ ├── data_USERS_4_0.bak │ ├── data_USERS_4_1.bak │ └── data_USERS_5_0.bak └── path └── path.rcd meta └── backupset_disk.ini
在数据库中查询表sys_backup_sets信息
[root@pr7 gaussdb]# zsql / as sysdba -q connected. SQL> select * from sys.sys_backup_sets; RECID TYPE STAGE STATUS INCREMENTAL_LEVEL TAG SCN LSN DEVICE_TYPE BASE_TAG DIR RESETLOGS POLICY RCY_ASN RCY_OFFSET RCY_LFN LRP_ASN LRP_OFFSET LRP_LFN START_TIME COMPLETION_TIME -------------------- ------------ ------------ ------------ ----------------- ---------------------------------------------------------------- -------------------- -------------------- ------------ ---------------------------------------------------------------- ---------------------------------------------------------------- ------------ ---------------------------------------------------------------- ------------ -------------------- -------------------- ------------ -------------------- -------------------- -------------------------------- --------------------------------2 2 4 0 0 20200119_163640 7620467342823425 8218862 0 /opt/gaussdb/media/roach/20200119_163640/data 0 3 3678 92424 3 3693 92428 2020-01-19 16:36:40.972994 2020-01-19 16:37:00.831938
3、增量备份数据库
增量备份只需在全备基础上指定–prior-backup-key即可。
[omm@pr7 roach]$ python GaussRoach.py --mode single -t backup --media-destination /opt/gaussdb/media --metadata-destination /opt/gaussdb/meta --prior-backup-key 20200119_163640 start run backup. Successfully backup data, backup key: 20200119_164634, 00:00:04 Performing backup completed. [omm@pr7 roach]$
查看备份信息,BKP TYPE为INCR,增量备份
[omm@pr7 roach]$ python GaussRoach.py --mode single -t show --all-backups --metadata-destination /opt/gaussdb/meta start run show. | BACKUP KEY |BKP TYPE|MEDIA | START TIME | END TIME | BKP SIZE | STATUS | |===============|========|======|===================|===================|============|===========| |20200119_163640| FULL | DISK |2020-01-19 16:36:40|2020-01-19 16:37:00| 527.2 MB | SUCCESS | |20200119_164634| INCR | DISK |2020-01-19 16:46:34|2020-01-19 16:46:39| 296 KB | SUCCESS | Performing show completed. [omm@pr7 roach]$ python GaussRoach.py --mode single -t show --last-full-backup --metadata-destination /opt/gaussdb/meta start run show. | BACKUP KEY |BKP TYPE|MEDIA | START TIME | END TIME | BKP SIZE | STATUS | |===============|========|======|===================|===================|============|===========| |20200119_163640| FULL | DISK |2020-01-19 16:36:40|2020-01-19 16:37:00| 527.2 MB | SUCCESS |
4、删除备份数据
删除指定备份集,删除后STATUS显示DELETE
[omm@pr7 roach]$ python GaussRoach.py --mode single -t delete --backup-key 20200119_164634 --media-destination /opt/gaussdb/media --metadata-destination /opt/gaussdb/meta start run delete. start delete backup data. Successfully delete backup data. Performing delete completed. [omm@pr7 roach]$ python GaussRoach.py --mode single -t show --all-backups --metadata-destination /opt/gaussdb/meta start run show. | BACKUP KEY |BKP TYPE|MEDIA | START TIME | END TIME | BKP SIZE | STATUS | |===============|========|======|===================|===================|============|===========| |20200119_163640| FULL | DISK |2020-01-19 16:36:40|2020-01-19 16:37:00| 527.2 MB | SUCCESS | |20200119_164634| INCR | DISK |2020-01-19 16:46:34|2020-01-19 16:46:39| 296 KB | DELETE | Performing show completed.
BTW:删除其中一个增量备份后,尝试发起增量备份报错,除非再发起一次全部
[omm@pr7 roach]$ python GaussRoach.py --mode single -t backup --media-destination /opt/gaussdb/media --metadata-destination /opt/gaussdb/meta --prior-backup-key 20200119_163640 start run backup. All backup keys are unavailable. Failed to do backup, All backup keys are unavailable. All backup keys are unavailable.
删除所有备份集,状态会全部显示为DELETE
[omm@pr7 roach]$ python GaussRoach.py --mode single -t delete --cascade --media-destination /opt/gaussdb/media --metadata-destination /opt/gaussdb/meta --backup-key=20200119_163640 start run delete. start delete backup data. Successfully delete backup data. Performing delete completed. [omm@pr7 roach]$ [omm@pr7 roach]$ python GaussRoach.py --mode single -t show --all-backups --metadata-destination /opt/gaussdb/meta start run show. | BACKUP KEY |BKP TYPE|MEDIA | START TIME | END TIME | BKP SIZE | STATUS | |===============|========|======|===================|===================|============|===========| |20200119_163640| FULL | DISK |2020-01-19 16:36:40|2020-01-19 16:37:00| 527.2 MB | DELETE | |20200119_164634| INCR | DISK |2020-01-19 16:46:34|2020-01-19 16:46:39| 296 KB | DELETE | Performing show completed.
转自墨天轮
- 点赞
- 收藏
- 关注作者
评论(0)