Skip to content

Commit 374d47f

Browse files
[Feature](backup) backup privileges catalogs and workloadgroups (#3382)
## Summary - Recreate the backup/restore global-scope documentation updates from #1442. - Add `GLOBAL` syntax updates and related examples for BACKUP/RESTORE/CANCEL/SHOW RESTORE statements. - Document `backup_*` and `reserve_*` properties for global backup and restore. ## Versions - [x] dev - [x] 4.x - [ ] 3.x - [ ] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Reference - Original PR: #1442 --------- Co-authored-by: zhangyuan <ayuanzhang@tencent.com>
1 parent ebfd612 commit 374d47f

20 files changed

Lines changed: 272 additions & 24 deletions

File tree

docs/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
## Description
1010

11-
This statement is used to back up the data under the specified database. This command is an asynchronous operation. After the submission is successful, you need to check the progress through the [SHOW BACKUP](./SHOW-BACKUP.md) command.
11+
This statement is used to back up the data under the specified database. This command is an asynchronous operation. After submission, you can check progress with the `SHOW BACKUP` command.
1212

1313
## Syntax
1414

1515
```sql
16-
BACKUP SNAPSHOT [<db_name>.]<snapshot_name>
16+
BACKUP [GLOBAL] SNAPSHOT [<db_name>.]<snapshot_name>
1717
TO `<repository_name>`
1818
[ { ON | EXCLUDE } ]
1919
( <table_name> [ PARTITION ( <partition_name> [, ...] ) ]
@@ -55,6 +55,9 @@ Data snapshot attributes, in the format: `<key>` = `<value>`,currently support
5555

5656
- "type" = "full": indicates that this is a full update (default)
5757
- "timeout" = "3600": The task timeout period, the default is one day. in seconds.
58+
- "backup_privilege" = "true": Whether to back up privileges. Use with `BACKUP GLOBAL`.
59+
- "backup_catalog" = "true": Whether to back up catalogs. Use with `BACKUP GLOBAL`.
60+
- "backup_workload_group" = "true": Whether to back up workload groups. Use with `BACKUP GLOBAL`.
5861

5962
## Access Control Requirements
6063

@@ -107,3 +110,18 @@ EXCLUDE (example_tbl);
107110
BACKUP SNAPSHOT example_db.snapshot_label3
108111
TO example_repo;
109112
```
113+
114+
5. Back up privileges, catalogs, and workload groups to repository example_repo:
115+
116+
```sql
117+
BACKUP GLOBAL SNAPSHOT snapshot_label5
118+
TO example_repo;
119+
```
120+
121+
6. Back up privileges and catalogs to repository example_repo:
122+
123+
```sql
124+
BACKUP GLOBAL SNAPSHOT snapshot_label6
125+
TO example_repo
126+
PROPERTIES ("backup_privilege" = "true", "backup_catalog" = "true");
127+
```

docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This statement is used to cancel an ongoing BACKUP task.
1313
## Syntax
1414

1515
```sql
16-
CANCEL BACKUP FROM <db_name>;
16+
CANCEL [GLOBAL] BACKUP [FROM <db_name>];
1717
```
1818

1919
## Parameters
@@ -29,3 +29,9 @@ The name of the database to which the backup task belongs.
2929
```sql
3030
CANCEL BACKUP FROM example_db;
3131
```
32+
33+
2. Cancel the GLOBAL BACKUP task.
34+
35+
```sql
36+
CANCEL GLOBAL BACKUP;
37+
```

docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This statement is used to cancel an ongoing RESTORE task.
1313
## Syntax
1414

1515
```sql
16-
CANCEL RESTORE FROM <db_name>;
16+
CANCEL [GLOBAL] RESTORE [FROM <db_name>];
1717
```
1818

1919
## Parameters
@@ -34,3 +34,8 @@ The name of the database to which the recovery task belongs.
3434
CANCEL RESTORE FROM example_db;
3535
```
3636

37+
2. Cancel the GLOBAL RESTORE task.
38+
39+
```sql
40+
CANCEL GLOBAL RESTORE;
41+
```

docs/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This statement is used to restore the data backed up by the BACKUP command to th
1313
## Syntax
1414

1515
```sql
16-
RESTORE SNAPSHOT [<db_name>.]<snapshot_name>
16+
RESTORE [GLOBAL] SNAPSHOT [<db_name>.]<snapshot_name>
1717
FROM `<repository_name>`
1818
[ { ON | EXCLUDE } ] (
1919
`<table_name>` [PARTITION (`<partition_name>`, ...)] [AS `<table_alias>`]
@@ -53,6 +53,9 @@ Restoration operation attributes, the format is `<key>` = `<value>`,currently
5353
- "atomic_restore" - : The data will be loaded into a temporary table first, and then the original table will be replaced atomically to ensure that the read and write of the target table are not affected during the recovery process.
5454
- "force_replace" : Force replace when the table exists and the schema is different with the backup table.
5555
- Note that to enable `force_replace`, you must enable `atomic_restore`
56+
- "reserve_privilege" = "true": Whether to restore privileges. Use with `RESTORE GLOBAL`.
57+
- "reserve_catalog" = "true": Whether to restore catalogs. Use with `RESTORE GLOBAL`.
58+
- "reserve_workload_group" = "true": Whether to restore workload groups. Use with `RESTORE GLOBAL`.
5659

5760
## Optional Parameters
5861

@@ -129,3 +132,29 @@ PROPERTIES
129132
"backup_timestamp"="2018-05-04-18-12-18"
130133
);
131134
```
135+
136+
4. Restore privileges, catalogs, and workload groups from backup snapshot_4 in example_repo, with time version "2018-05-04-18-12-18".
137+
138+
```sql
139+
RESTORE GLOBAL SNAPSHOT `snapshot_4`
140+
FROM `example_repo`
141+
EXCLUDE ( `backup_tbl` )
142+
PROPERTIES
143+
(
144+
"backup_timestamp"="2018-05-04-18-12-18"
145+
);
146+
```
147+
148+
5. Restore privileges and workload groups from backup snapshot_5 in example_repo, with time version "2018-05-04-18-12-18".
149+
150+
```sql
151+
RESTORE GLOBAL SNAPSHOT `snapshot_5`
152+
FROM `example_repo`
153+
EXCLUDE ( `backup_tbl` )
154+
PROPERTIES
155+
(
156+
"backup_timestamp"="2018-05-04-18-12-18",
157+
"reserve_privilege" = "true",
158+
"reserve_workload_group" = "true"
159+
);
160+
```

docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This statement is used to view RESTORE tasks
1313
## Syntax
1414

1515
```SQL
16-
SHOW [BRIEF] RESTORE [FROM <db_name>]
16+
SHOW [BRIEF] [GLOBAL] RESTORE [FROM <db_name>]
1717
```
1818

1919
## Parameters
@@ -57,3 +57,8 @@ The name of the database to which the recovery task belongs.
5757
SHOW RESTORE FROM example_db;
5858
```
5959

60+
2. View the latest GLOBAL RESTORE task.
61+
62+
```sql
63+
SHOW GLOBAL RESTORE;
64+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
## 描述
1010

11-
该语句用于备份指定数据库下的数据。该命令为异步操作,提交成功后,需通过 [SHOW BACKUP](./SHOW-BACKUP.md) 命令查看进度。
11+
该语句用于备份指定数据库下的数据。该命令为异步操作,提交成功后,需通过 `SHOW BACKUP` 命令查看进度。
1212

1313
## 语法
1414

1515
```sql
16-
BACKUP SNAPSHOT [<db_name>.]<snapshot_name>
16+
BACKUP [GLOBAL] SNAPSHOT [<db_name>.]<snapshot_name>
1717
TO `<repository_name>`
1818
[ { ON | EXCLUDE } ]
1919
( <table_name> [ PARTITION ( <partition_name> [, ...] ) ]
@@ -55,6 +55,9 @@ TO `<repository_name>`
5555

5656
- "type" = "full":表示这是一次全量更新(默认)
5757
- "timeout" = "3600":任务超时时间,默认为一天。单位秒。
58+
- "backup_privilege" = "true":是否备份权限信息,与 `BACKUP GLOBAL` 一起使用。
59+
- "backup_catalog" = "true":是否备份 catalog 信息,与 `BACKUP GLOBAL` 一起使用。
60+
- "backup_workload_group" = "true":是否备份 workload group 信息,与 `BACKUP GLOBAL` 一起使用。
5861

5962
## 权限控制
6063

@@ -108,3 +111,17 @@ BACKUP SNAPSHOT example_db.snapshot_label3
108111
TO example_repo;
109112
```
110113

114+
5. 备份权限、catalog 和 workload group 信息到仓库 example_repo 中:
115+
116+
```sql
117+
BACKUP GLOBAL SNAPSHOT snapshot_label5
118+
TO example_repo;
119+
```
120+
121+
6. 备份权限和 catalog 信息到仓库 example_repo 中:
122+
123+
```sql
124+
BACKUP GLOBAL SNAPSHOT snapshot_label6
125+
TO example_repo
126+
PROPERTIES ("backup_privilege" = "true", "backup_catalog" = "true");
127+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## 语法
1414

1515
```sql
16-
CANCEL BACKUP FROM <db_name>;
16+
CANCEL [GLOBAL] BACKUP [FROM <db_name>];
1717
```
1818

1919
## 参数
@@ -30,3 +30,8 @@ CANCEL BACKUP FROM <db_name>;
3030
CANCEL BACKUP FROM example_db;
3131
```
3232

33+
2. 取消 GLOBAL BACKUP 任务。
34+
35+
```sql
36+
CANCEL GLOBAL BACKUP;
37+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## 语法
1414

1515
```sql
16-
CANCEL RESTORE FROM <db_name>;
16+
CANCEL [GLOBAL] RESTORE [FROM <db_name>];
1717
```
1818

1919
## 参数
@@ -34,3 +34,8 @@ CANCEL RESTORE FROM <db_name>;
3434
CANCEL RESTORE FROM example_db;
3535
```
3636

37+
2. 取消 GLOBAL RESTORE 任务。
38+
39+
```sql
40+
CANCEL GLOBAL RESTORE;
41+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## 语法
1414

1515
```sql
16-
RESTORE SNAPSHOT [<db_name>.]<snapshot_name>
16+
RESTORE [GLOBAL] SNAPSHOT [<db_name>.]<snapshot_name>
1717
FROM `<repository_name>`
1818
[ { ON | EXCLUDE } ] (
1919
`<table_name>` [PARTITION (`<partition_name>`, ...)] [AS `<table_alias>`]
@@ -51,6 +51,9 @@ FROM `<repository_name>`
5151
- "atomic_restore":先将数据加载到临时表中,再以原子方式替换原表,确保恢复过程中不影响目标表的读写。
5252
- "force_replace":当表存在且架构与备份表不同时,强制替换。
5353
- 注意,要启用 "force_replace",必须启用 "atomic_restore"
54+
- "reserve_privilege" = "true":是否恢复权限信息,与 `RESTORE GLOBAL` 一起使用。
55+
- "reserve_catalog" = "true":是否恢复 catalog 信息,与 `RESTORE GLOBAL` 一起使用。
56+
- "reserve_workload_group" = "true":是否恢复 workload group 信息,与 `RESTORE GLOBAL` 一起使用。
5457

5558
## 可选参数
5659

@@ -128,3 +131,28 @@ PROPERTIES
128131
);
129132
```
130133

134+
4. 从 example_repo 中恢复备份 snapshot_4 的权限、catalog 和 workload group 信息,时间版本为 "2018-05-04-18-12-18"。
135+
136+
```sql
137+
RESTORE GLOBAL SNAPSHOT `snapshot_4`
138+
FROM `example_repo`
139+
EXCLUDE ( `backup_tbl` )
140+
PROPERTIES
141+
(
142+
"backup_timestamp"="2018-05-04-18-12-18"
143+
);
144+
```
145+
146+
5. 从 example_repo 中恢复备份 snapshot_5 的权限和 workload group 信息,时间版本为 "2018-05-04-18-12-18"。
147+
148+
```sql
149+
RESTORE GLOBAL SNAPSHOT `snapshot_5`
150+
FROM `example_repo`
151+
EXCLUDE ( `backup_tbl` )
152+
PROPERTIES
153+
(
154+
"backup_timestamp"="2018-05-04-18-12-18",
155+
"reserve_privilege" = "true",
156+
"reserve_workload_group" = "true"
157+
);
158+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## 语法
1414

1515
```SQL
16-
SHOW [BRIEF] RESTORE [FROM <db_name>]
16+
SHOW [BRIEF] [GLOBAL] RESTORE [FROM <db_name>]
1717
```
1818

1919
## 参数
@@ -56,3 +56,9 @@ SHOW [BRIEF] RESTORE [FROM <db_name>]
5656
```sql
5757
SHOW RESTORE FROM example_db;
5858
```
59+
60+
2. 查看最近一次 GLOBAL RESTORE 任务。
61+
62+
```sql
63+
SHOW GLOBAL RESTORE;
64+
```

0 commit comments

Comments
 (0)