Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature](backup) backup privileges catalogs and workloadgroups #1442

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This statement is used to back up the data under the specified database. This co
grammar:

```sql
BACKUP SNAPSHOT [db_name].{snapshot_name}
BACKUP [GLOBAL] SNAPSHOT [db_name].{snapshot_name}
TO `repository_name`
[ON|EXCLUDE] (
`table_name` [PARTITION (`p1`, ...)],
Expand All @@ -56,6 +56,9 @@ illustrate:
- PROPERTIES currently supports the following properties:
- "type" = "full": indicates that this is a full update (default)
- "timeout" = "3600": The task timeout period, the default is one day. in seconds.
- "backup_privilege" = "true":Whether to backup privileges,use with BACKUP GLOBAL.
- "backup_catalog" = "true":Whether to backup catalogs,use with BACKUP GLOBAL.
- "backup_workload_group" = "true":Whether to backup workload groups,use with BACKUP GLOBAL.

### Example

Expand Down Expand Up @@ -95,6 +98,21 @@ BACKUP SNAPSHOT example_db.snapshot_label3
TO example_repo;
```

5. buckup privileges,catalog and workloadgroup to the repository example_repo:

```sql
BACKUP GLOBAL SNAPSHOT snapshot_label5
TO example_repo;
```

6.buckup privileges and catalog to the repository example_repo:

```sql
BACKUP GLOBAL SNAPSHOT snapshot_label6
TO example_repo
PROPERTIES ("backup_privilege" = "true", "backup_catalog"="true");
```

### Keywords

BACKUP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This statement is used to cancel an ongoing BACKUP task.
grammar:

```sql
CANCEL BACKUP FROM db_name;
CANCEL [GLOBAL] BACKUP [FROM db_name];
```

### Example
Expand All @@ -48,6 +48,12 @@ CANCEL BACKUP FROM db_name;
CANCEL BACKUP FROM example_db;
```

2. Cancel the GLOBAL BACKUP task.

```sql
CANCEL GLOBAL BACKUP;
```

### Keywords

CANCEL, BACKUP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This statement is used to cancel an ongoing RESTORE task.
grammar:

```sql
CANCEL RESTORE FROM db_name;
CANCEL [GLOBAL] RESTORE [FROM db_name];
```

Notice:
Expand All @@ -52,6 +52,12 @@ Notice:
CANCEL RESTORE FROM example_db;
```

2. Cancel the GLOBAL RESTORE task.

```sql
CANCEL GLOBAL RESTORE;
```

### Keywords

CANCEL, RESTORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This statement is used to restore the data backed up by the BACKUP command to th
grammar:

```sql
RESTORE SNAPSHOT [db_name].{snapshot_name}
RESTORE [GLOBAL] SNAPSHOT [db_name].{snapshot_name}
FROM `repository_name`
[ON|EXCLUDE] (
`table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`],
Expand All @@ -63,6 +63,9 @@ illustrate:
- "meta_version" = 40: Use the specified meta_version to read the previously backed up metadata. Note that this parameter is used as a temporary solution and is only used to restore the data backed up by the old version of Doris. The latest version of the backup data already contains the meta version, no need to specify it.
- "clean_tables": Indicates whether to clean up tables that do not belong to the restore target. For example, if the target db before the restore has tables that are not present in the snapshot, specifying `clean_tables` can drop these extra tables and move them into the recycle bin during the restore.
- "clean_partitions": Indicates whether to clean up partitions that do not belong to the restore target. For example, if the target table before the restore has partitions that are not present in the snapshot, specifying `clean_partitions` can drop these extra partitions and move them into the recycle bin during the restore.
- "reserve_privilege" = "true":Whether to restore privileges,use with RESTORE GLOBAL.
- "reserve_catalog" = "true":Whether to restore catalogs,use with RESTORE GLOBAL.
- "reserve_workload_group" = "true":Whether to restore workload groups,use with RESTORE GLOBAL.

### Example

Expand Down Expand Up @@ -107,6 +110,33 @@ PROPERTIES
);
```

4. Restore privileges,catalogs, workload groups in backup snapshot_4 from example_rep,the time version is "2018-05-04-18-12-18".

```sql
RESTORE GLOBAL SNAPSHOT `snapshot_4`
FROM `example_repo`
EXCLUDE ( `backup_tbl` )
PROPERTIES
(
"backup_timestamp"="2018-05-04-18-12-18"
);
```

5. Restore privileges and workload groups in backup snapshot_5 from example_rep,the time version is "2018-05-04-18-12-18".

```sql
RESTORE GLOBAL SNAPSHOT `snapshot_5`
FROM `example_repo`
EXCLUDE ( `backup_tbl` )
PROPERTIES
(
"backup_timestamp"="2018-05-04-18-12-18",
"reserve_privilege" = "true",
"reserve_workload_group"="true"
);
```


### Keywords

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This statement is used to view BACKUP tasks
grammar:

```sql
SHOW BACKUP [FROM db_name]
SHOW [GLOBAL] BACKUP [FROM db_name]
[WHERE SnapshotName ( LIKE | = ) 'snapshot name']
```

Expand Down Expand Up @@ -74,6 +74,12 @@ illustrate:
SHOW BACKUP FROM example_db;
```

2. View the last GLOBAL BACKUP task.

```sql
SHOW GLOBAL BACKUP;
```

### Keywords

SHOW, BACKUP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This statement is used to view RESTORE tasks
grammar:

```SQL
SHOW [BRIEF] RESTORE [FROM DB_NAME]
SHOW [BRIEF] [GLOBAL] RESTORE [FROM DB_NAME]
```

illustrate:
Expand Down Expand Up @@ -77,7 +77,11 @@ illustrate:
```sql
SHOW RESTORE FROM example_db;
```
2. View the latest GLOBAL RESTORE task.

```sql
SHOW GLOBAL RESTORE;
```
### Keywords

SHOW, RESTORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ BACKUP
语法:

```sql
BACKUP SNAPSHOT [db_name].{snapshot_name}
BACKUP [GLOBAL] SNAPSHOT [db_name].{snapshot_name}
TO `repository_name`
[ON|EXCLUDE] (
`table_name` [PARTITION (`p1`, ...)],
Expand All @@ -57,7 +57,11 @@ PROPERTIES ("key"="value", ...);
- EXCLUDE 子句中标识不需要备份的表和分区。备份除了指定的表或分区之外这个数据库中所有表的所有分区数据。
- PROPERTIES 目前支持以下属性:
- "type" = "full":表示这是一次全量更新(默认)
- "timeout" = "3600":任务超时时间,默认为一天。单位秒。
- "timeout" = "3600":任务超时时间,默认为一天。单位秒。
- "backup_privilege" = "true": 备份权限信息, 和BACKUP GLOBAL一起使用。
- "backup_catalog" = "true":备份catalog信息,和BACKUP GLOBAL一起使用。
- "backup_workload_group" = "true":备份workload group信息,和BACKUP GLOBAL一起使用。


### Example

Expand Down Expand Up @@ -93,10 +97,27 @@ EXCLUDE (example_tbl);
4. 全量备份 example_db 下的表到仓库 example_repo 中:

```sql
BACKUP SNAPSHOT example_db.snapshot_label3
BACKUP SNAPSHOT example_db.snapshot_label4
TO example_repo;
```


5. 备份权限、catalog、workloadgroup信息到仓库 example_repo 中:

```sql
BACKUP GLOBAL SNAPSHOT snapshot_label5
TO example_repo;
```

6. 备份权限和catalog信息到仓库 example_repo 中:

```sql
BACKUP GLOBAL SNAPSHOT snapshot_label6
TO example_repo
PROPERTIES ("backup_privilege" = "true", "backup_catalog"="true");
```


### Keywords

```text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CANCEL BACKUP
语法:

```sql
CANCEL BACKUP FROM db_name;
CANCEL [GLOBAL] BACKUP [FROM db_name];
```

### Example
Expand All @@ -48,6 +48,12 @@ CANCEL BACKUP FROM db_name;
CANCEL BACKUP FROM example_db;
```

2. 取消全局的BACKUP 任务。

```sql
CANCEL GLOBAL BACKUP;
```

### Keywords

CANCEL, BACKUP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CANCEL RESTORE
语法:

```sql
CANCEL RESTORE FROM db_name;
CANCEL [GLOBAL] RESTORE [FROM db_name];
```

注意:
Expand All @@ -52,6 +52,12 @@ CANCEL RESTORE FROM db_name;
CANCEL RESTORE FROM example_db;
```

2. 取消全局的RESTORE 任务。

```sql
CANCEL GLOBAL RESTORE;
```

### Keywords

CANCEL, RESTORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RESTORE
语法:

```sql
RESTORE SNAPSHOT [db_name].{snapshot_name}
RESTORE [GLOBAL] SNAPSHOT [db_name].{snapshot_name}
FROM `repository_name`
[ON|EXCLUDE] (
`table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`],
Expand All @@ -62,6 +62,9 @@ PROPERTIES ("key"="value", ...);
- "meta_version" = 40:使用指定的 meta_version 来读取之前备份的元数据。注意,该参数作为临时方案,仅用于恢复老版本 Doris 备份的数据。最新版本的备份数据中已经包含 meta version,无需再指定。
- "clean_tables": 表示是否清理不属于恢复目标的表。例如,如果恢复之前的目标数据库有备份中不存在的表,指定 `clean_tables` 就可以在恢复期间删除这些额外的表并将其移入回收站。
- "clean_partitions":表示是否清理不属于恢复目标的分区。例如,如果恢复之前的目标表有备份中不存在的分区,指定 `clean_partitions` 就可以在恢复期间删除这些额外的分区并将其移入回收站。
- "reserve_privilege" = "true", 表示恢复权限信息,和RESTORE GLOBAL一起使用。
- "reserve_catalog" = "true", 表示恢复catalog信息,和RESTORE GLOBAL一起使用。
- "reserve_workload_group"="true", 表示恢复workload group信息,和RESTORE GLOBAL一起使用。

### Example

Expand Down Expand Up @@ -106,6 +109,32 @@ PROPERTIES
);
```

4. 从 example_repo 中恢复备份权限、catalog和workload group信息,时间版本为 "2018-05-04-18-12-18"。

```sql
RESTORE GLOBAL SNAPSHOT `snapshot_4`
FROM `example_repo`
EXCLUDE ( `backup_tbl` )
PROPERTIES
(
"backup_timestamp"="2018-05-04-18-12-18"
);
```

5. 从 example_repo 中恢复备份权限和workload group信息,时间版本为 "2018-05-04-18-12-18"。

```sql
RESTORE GLOBAL SNAPSHOT `snapshot_5`
FROM `example_repo`
EXCLUDE ( `backup_tbl` )
PROPERTIES
(
"backup_timestamp"="2018-05-04-18-12-18",
"reserve_privilege" = "true",
"reserve_workload_group"="true"
);
```

### Keywords

RESTORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SHOW BACKUP
语法:

```sql
SHOW BACKUP [FROM db_name]
SHOW [GLOBAL] BACKUP [FROM db_name]
[WHERE SnapshotName ( LIKE | = ) 'snapshot name' ]
```

Expand Down Expand Up @@ -73,7 +73,11 @@ SHOW BACKUP
```sql
SHOW BACKUP FROM example_db;
```

2. 查看 最后一次 GLOBAL BACKUP 任务。

```sql
SHOW GLOBAL BACKUP;
```
### Keywords

SHOW, BACKUP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SHOW RESTORE
语法:

```SQL
SHOW [BRIEF] RESTORE [FROM DB_NAME]
SHOW [BRIEF] [GLOBAL] RESTORE [FROM DB_NAME]
```

说明:
Expand Down Expand Up @@ -77,6 +77,11 @@ SHOW [BRIEF] RESTORE [FROM DB_NAME]
```sql
SHOW RESTORE FROM example_db;
```
2. 查看 最后一次 GLOBAL RESTORE 任务。

```sql
SHOW GLOBAL RESTORE;
```

### Keywords

Expand Down