This topic describes how to initiate a tenant restore through the API.
Call parameters
API constraints
If a password is set, you must authenticate. For more information, see API hybrid encryption.
Request path
POST /api/v1/tenant/restore
Request parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| data_backup_uri | string | Yes | "file:///data/backup/data" | The path of the source data backup file. |
| archive_log_uri | string | No | "file:///data/backup/clog" | The destination for archiving logs. If not specified, the value of data_backup_uri is used. |
| restore_tenant_name | string | Yes | "new_tenant" | The name of the tenant to be restored. |
| time_stamp | time.time | No | "2006-01-02T15:04:05.000+08:00" | The restore timestamp. The format is 2006-01-02T15:04:05.000Z08:00. If specified, the restore is performed up to the specified timestamp, including the timestamp. |
| scn | int | No | 1728727696264250400 | The SCN to which the restore is to be performed. If specified, the restore is performed up to the specified SCN, including the SCN. |
| ha_high_thread_score | int | No | 10 | The number of current working threads for the high-priority thread in high availability. The value range is [0, 100]. The default value is 10 if not specified. |
| zone_list | []ZoneParam | Yes | For more information, see the Data structure of ZoneParam section. | The resource specifications of the tenant and the distribution of replicas. |
| primary_zone | string | No | "random" | The primary zone of the tenant. The default value is random. |
| concurrency | int | No | 2 | The concurrency for data restore. If not specified, the number of MAX_CPU allocated to the tenant is used. |
| decryption | []string | No | {"pwd1"} | The password for the backup set. All passwords must be specified. |
| kms_encrypt_info | string | No | N/A | The key management information. If the data is not encrypted or the key management service can be accessed when the data is restored, this parameter can be omitted. |
The data structure of ZoneParam:
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| name | string | Yes | zone1 | The name of the zone. |
| replica_type | string | No | FULL | The replica type of the tenant on the zone. Valid values include FULL (full-featured replica) and READONLY (read-only replica). The default value is FULL. |
| unit_config_name | string | Yes | s1 | The resource specifications of the tenant resource pool on the zone. |
| unit_num | int | Yes | 1 | The number of units of the tenant on the zone. |
Return result
| Parameter | Type | Description |
|---|---|---|
| successful | bool | Whether the request is successful. |
| timestamp | time.Time | The timestamp when the server completes the request. |
| duration | int | The time (in milliseconds) taken by the server to process the request. |
| status | int | The HTTP status code. |
| traceId | string | The Trace ID of the request. |
| data | DagDetailDTO | The asynchronous task information. For more information, see the Data structure of DagDetailDTO section. |
| error | ApiError | The error generated during the request, which contains the following information:
|
The data structure of DagDetailDTO is as follows:
| Parameter | Type | Description |
|---|---|---|
| id | string | The universal ID of the DAG. |
| dag_id | int | The ID of the DAG, which is the primary key in OceanBase Database. |
| name | string | The name of the DAG. |
| stage | int | The current execution stage of the DAG. |
| max_stage | int | The total number of stages in the execution process of the DAG. |
| state | string | The execution status of the DAG. |
| operator | string | The type of the DAG execution operation. |
| start_time | time.Time | The start time of the DAG execution. |
| end_time | time.Time | The end time of the DAG execution. |
| additional_data | map[string]any | Other data of the DAG. |
| nodes | []NodeDetailDTO | Information about all nodes in the DAG. For more information, see Get node details. |
Examples
Request example
POST 10.10.10.1:2886/api/v1/tenant/restore
{
"data_backup_uri": "oss://oss-328067-1014-obshell/backup/archive/test/1/1002/data?host=oss-cn-hangzhou.aliyuncs.com",
"restore_tenant_name": "rt2",
"zone_list":
[
{
"name": "zone1",
"unit_config_name": "unit1",
"unit_num": 1
}
],
"archive_log_uri": "oss://oss-328067-1014-obshell/backup/archive/test/1/1002/clog?host=oss-cn-hangzhou.aliyuncs.com"
}
Response example
{
"successful": true,
"timestamp": "2024-01-09T17:11:43.385889278+08:00",
"duration": 1,
"status": 200,
"traceId": "877fe32b83634153",
"data": {
"id": "22130706433028869",
"dag_id": 4,
"name": "Restore backup_rt2",
"stage": 1,
"max_stage": 5,
"state": "READY",
"operator": "RUN",
"start_time": "2024-01-09T17:11:43.384630643+08:00",
"end_time": "2024-01-09T17:11:43.384630643+08:00",
"additional_data": null,
"nodes": null
}
}
References
You can also call the API through SDK methods in addition to the CLI.
For more information about how to call the API through obshell-sdk-python, see Initiate a restore for a single tenant.
For more information about how to call the API through obshell-sdk-go, see Initiate a restore for a single tenant.