GaussDB T 通过zsql backup database备份数据库

举报
GaussDB小粉 发表于 2020/01/20 10:12:59 2020/01/20
【摘要】 本文介绍通过zsql命令行执行backup database对华为GaussDB T数据库来完成全备、增量备份,以及如何查看备份信息。

在上一篇文章中介绍了如何通过Roach完成对GaussDB T数据库的备份,详细请参考《GaussDB T 备份工具 Roach 备份数据库》https://www.modb.pro/db/15144

在安装完之后由于exp\imp\load\dump等命令都集成在zsql中,尝试执行backup database;命令可以正常执行,研究后发现可以直接在zsql中完成对数据库的全备,增量备份,本文介绍相关内容。

backup database 命令如下:

BACKUP DATABASE { FULL | INCREMENTAL LEVEL level [CUMULATIVE]}
	{ FORMAT 'dest_format' }
	[ AS [ZLIB | ZSTD | LZ4] COMPRESSED BACKUPSET [LEVEL compress_level]]
	[ TAG 'tag' ] [ PARALLELISM count ] [ SECTION THRESHOLD size ]
	[ EXCLUDE FOR TABLESPACE space_list]

1、全备数据库

直接执行backup database;默认全备

[omm@pr7 ~]$ zsql / as sysdba -q

connected.


SQL> backup database;     

Succeed.

compressed backupset level指定压缩等级,等级为1到9,parallelism指定并行度。

[omm@pr7 roach]$ zsql / as sysdba -q

connected.


SQL> backup database full as compressed backupset level 9 parallelism 5;     

Succeed.

2、增量备份数据库

第一次增量备份(基于全备)

SQL> backup database incremental level 1 ;

Succeed.

再次增量备份(基于全备和第一次增备)

SQL> backup database incremental level 1 ;

Succeed.

3、查看备份数据

查看sys_backup_sets表数据:

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                 
-------------------- ------------ ------------ ------------ ----------------- ---------------------------------------------------------------- -------------------- -------------------- ------------ ---------------------------------------------------------------- ---------------------------------------------------------------- ------------ ---------------------------------------------------------------- ------------ -------------------- -------------------- ------------ -------------------- -------------------- -------------------------------- --------------------------------1                    1            4            0            0                 632762230746442_7599842243395585                                 7599842243395585     8209337              0                                                                             /opt/gaussdb/data/backup/632762230746442                         0                                                                             2            495841               90846                2            514103               91352                2020-01-19 15:17:10.746442       2020-01-19 15:17:22.522912      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                    2            4            0            1                 20200119_164634                                                  7622923667386369     8221484              0            20200119_163640                                                  /opt/gaussdb/media/roach/20200119_164634/data                    0                                                                             4            1035                 92602                4            1035                 92602                2020-01-19 16:46:35.057972       2020-01-19 16:46:39.185320      4                    2            4            0            0                 20200119_170226                                                  7627167981588481     8222914              0                                                                             /opt/gaussdb/media/roach/20200119_170226/data                    0                                                                             5            564                  92811                5            595                  92819                2020-01-19 17:02:26.635634       2020-01-19 17:03:07.916784      5                    1            4            0            0                 632769723321125_7632068255322113                                 7633362093559809     8226302              0                                                                             /opt/gaussdb/data/backup/632769723321125                         0                                                                             6            1304                 93071                6            1456                 93112                2020-01-19 17:22:03.321125       2020-01-19 17:27:03.502208      6                    2            4            0            1                 632770599546443_7635811608190977                                 7635811608190977     8227680              0            20200119_170226                                                  /opt/gaussdb/data/backup/632770599546443                         0                                                                             7            391                  93273                7            391                  93273                2020-01-19 17:36:39.546443       2020-01-19 17:36:43.675981      7                    2            4            0            1                 632774794609817_7653852719480833                                 7653887316770817     8238905              0            632770599546443_7635811608190977                                 /opt/gaussdb/data/backup/632774794609817                         0                                                                             8            4433                 94208                8            4572                 94290                2020-01-19 18:46:34.609817       2020-01-19 18:46:39.263797      7 rows fetched.

如果没指定备份目录,备份文件默认存在$GSDB_DATA/backup目录下,

[omm@pr7 ~]$ echo $GSDB_DATA/opt/gaussdb/data
[root@pr7 backup]# tree.
├── 631093557604141
│   ├── arch_1_0.bak
│   ├── 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
├── 632762230746442
│   ├── arch_2_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
├── 632769671866582
├── 632769681314631
├── 632769687738306
├── 632769696722384
├── 632769723321125
│   ├── arch_6_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
└── 632770599546443
    ├── arch_7_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

8 directories, 47 files
[root@pr7 backup]# pwd/opt/gaussdb/data/backup
[root@pr7 backup]# ls -lrttotal 16
drwx------ 2 omm dbgrp 4096 Dec 31 07:46 631093557604141
drwx------ 2 omm dbgrp 4096 Jan 19 15:17 632762230746442
drwx------ 2 omm dbgrp    6 Jan 19 17:21 632769671866582
drwx------ 2 omm dbgrp    6 Jan 19 17:21 632769681314631
drwx------ 2 omm dbgrp    6 Jan 19 17:21 632769687738306
drwx------ 2 omm dbgrp    6 Jan 19 17:21 632769696722384
drwx------ 2 omm dbgrp 4096 Jan 19 17:27 632769723321125
drwx------ 2 omm dbgrp 4096 Jan 19 17:36 632770599546443
[root@pr7 backup]# du -sh *2.1G    631093557604141
1.9G    632762230746442
0       632769671866582
0       632769681314631
0       632769687738306
0       632769696722384
538M    632769723321125
17M     632770599546443
25M     632774794609817


转自墨天轮

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。