Feature description
This API is used to create a backup strategy for a cluster. It allows you to set the backup schedule cycle, time, and storage address, as well as data cleanup and alert thresholds.
Call instructions
Interface constraints
The caller must have the permissions to create backup and restore for the cluster.
The caller must be authenticated through OCP application services.
Request path
POST /api/v2/ob/clusters/{id}/backup/config/backupStrategy
path:
Parameter |
Type |
Required |
Example Value |
Description |
|---|---|---|---|---|
| id | Integer | Yes | 1 | The ID of the cluster for which the backup strategy is to be created. |
Request parameters
Parameter |
Type |
Required |
Example Value |
Description |
|---|---|---|---|---|
| backupMode | String | Yes | LOGICAL_BACKUP | The backup mode. Valid values: |
| obBackupScheduleConfig | Object | Yes | NA | The backup schedule configuration. For more information, see Data structure of obBackupScheduleConfig. |
| obBackupThresholdConfig | Object | Yes | NA | The backup alert threshold configuration. For more information, see Data structure of obBackupThresholdConfig. |
| obBackupServiceStorageConfig | Object | Yes | NA | The backup storage configuration. For more information, see Data structure of obBackupServiceStorageConfig. |
| secondaryBackupEnabled | Boolean | No | false | The secondary backup switch. The default value is false. OceanBase Database V2.2.77 and later support secondary backup. |
| obSecondaryBackupConfig | Object | No | NA | The secondary backup configuration. For more information, see Data structure of obSecondaryBackupConfig. |
Data structure of obBackupScheduleConfig
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| backupScheduleMode | String | Yes | The backup schedule period. Valid values: WEEK and MONTH. |
| backupScheduleEnabled | Boolean | Yes | The backup switch. |
| backupScheduleTime | OffsetTime | Yes | The backup schedule time, for example, "02:00:00.000+08:00". |
| dayAndDataBackupModelMap | Map | Yes | The mapping between the schedule days and the data backup modes. For example, { "2": "FULL_BACKUP", "4": "FULL_BACKUP", "6": "INCREMENTAL_BACKUP" } indicates that full data backup is performed on Tuesday, Thursday, and Saturday, and incremental data backup is performed on Saturday. |
| startLogBackup | Boolean | Yes | Specifies whether to enable log backup. Generally, it is set to true. |
| cleanEnabled | Boolean | No | The switch for the cleanup of expired data. |
| backupDataRetentionDays | Long | No | The number of days for which backup data is retained. For example, if you set the value to 7, at least the most recent seven days of backup data is retained. This parameter takes effect only when cleanEnabled is set to true. |
| cleanScheduleTime | OffsetTime | No | The schedule time for the cleanup of expired data. |
Data structure of obBackupThresholdConfig
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| dataBackupTimeoutMinutes | Long | Yes | The timeout period for data backup, in minutes. |
| noSuccessfulDataBackupAlarmDays | Long | Yes | The maximum number of days for which no successful data backup triggers an alert. |
| libObLogExpireDays | Long | No | The retention period for liboblogs. This parameter is valid only in logical backup mode. |
| logBackupDelaySeconds | Long | Yes | The log backup delay threshold, in seconds. |
Data structure of obBackupServiceStorageConfig
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| configName | String | Yes | The name of the storage configuration. |
| obBackupStorageBaseInfo | Object | Yes | The basic parameters of the storage configuration. |
| |--backupStorageType | String | Yes | The storage type. Valid values: BACKUP_STORAGE_FILE, BACKUP_STORAGE_OSS, BACKUP_STORAGE_COS, and BACKUP_STORAGE_S3. |
| |--storageUrl | String | Yes | The storage directory. Specify a directory without a protocol, such as /obbackup/ or osstest/backup. |
| |--ossAccessKey | Object | No | The information about the OSS instance. This parameter is valid only when backupStorageType is set to BACKUP_STORAGE_OSS. |
| |--endpoint | String | Yes | The access domain name. |
| |--accessKeyId | String | Yes | The access user. |
| |--accessKeySecret | String | Yes | The access key. |
| |--cosAccessKey | Object | No | The information about the COS instance. This parameter is valid only when backupStorageType is set to BACKUP_STORAGE_COS. |
| |--endpoint | String | Yes | The access domain name. |
| |--accessKeyId | String | Yes | The access user. |
| |--accessKeySecret | String | Yes | The access key. |
| |--appId | String | Yes | The application ID. |
| |--s3AccessKey | Object | No | The information about the S3 instance. This parameter is valid only when backupStorageType is set to BACKUP_STORAGE_S3. |
| |--endpoint | String | Yes | The access domain name. |
| |--accessKeyId | String | Yes | The access user. |
| |--accessKeySecret | String | Yes | The access key. |
| |--region | String | Yes | The region. |
| |--alarmStoragePercentageThreshold | Long | Yes | The backup storage capacity alert threshold. Specify a value in the range of 0 to 100. |
| storageId | Long | No | The ID of the storage configuration. |
| serviceType | String | No | The service type. Valid values: BACKUP_RESTORE_SERVICE (logical backup and restore), OB_CLUSTER (physical backup and restore), and OTHERS. |
| serviceId | Long | No | The ID of the service. |
| serviceName | String | No | The name of the service. |
| hostIdList | Array | No | The list of host IDs for global restore. |
Data structure of obSecondaryBackupConfig
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| scheduleConfig | Object | Yes | The secondary backup schedule configuration. |
| |--dataBackupScheduleEnabled | Boolean | Yes | The switch for data secondary backup. |
| |--logBackupScheduleEnabled | Boolean | Yes | The switch for log secondary backup. |
| |--logSecondaryBackupPeriod | String | Yes | The schedule period for log secondary backup. Valid value: ONCE_A_DAY. |
| storageConfig | Object | Yes | The storage configuration. For more information, see Data structure of obBackupServiceStorageConfig. |
Response
Parameter |
Type |
Description |
|---|---|---|
| data | Object | The general response of the backup object. For more information, see BackupCommonResponse. |
| successful | Boolean | Indicates whether the request is successful. |
| timestamp | Datetime | The timestamp when the server finishes the request. |
| duration | Integer | The time taken by the server to process the request, in milliseconds. |
| status | Integer | The HTTP status code that conforms to the HTTP Status specification. |
| traceId | String | The Trace ID of the request, which is used to troubleshoot problems. |
| server | String | The address of the application service that responds to the request. |
Data structure of BackupCommonResponse
Parameter |
Type |
Description |
|---|---|---|
| obBackupTaskType | String | The type of the backup operation. For example, "CREATE_BACKUP_STRATEGY". |
| backupObjectOpsResultList | Array | The list of backup object operation results. |
| |--obBackupObjectList | Array | The list of backup objects. |
| |--clusterId | Long | The cluster ID. |
| |--tenantId | Long | The tenant ID. |
| |--backupDimension | String | The backup dimension. For example, CLUSTER and TENANT indicate cluster backup and tenant backup respectively. Currently, tenant backup is not supported. |
| |--beSuccessful | Boolean | Indicates whether the operation is successful. |
| |--taskIdList | Array | The task number list, which is returned when an asynchronous task exists. |
| |--errorCode | Object | The error code. |
| |--hint | String | The hint message. |
Example
Request example
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| dataBackupTimeoutMinutes | Long | Yes | The timeout period for data backup, in minutes. |
| noSuccessfulDataBackupAlarmDays | Long | Yes | The consecutive number of days exceeding which an alert for no successful backup tasks is triggered. |
| libObLogExpireDays | Long | No | The number of days for retaining liboblog. This parameter is valid only for logical backup. |
| logBackupDelaySeconds | Long | Yes | The log backup delay threshold, in seconds. |
Data structure of obBackupServiceStorageConfig
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| configName | String | Yes | The name of the storage configuration. |
| obBackupStorageBaseInfo | Object | Yes | The basic parameters of the storage configuration. |
| |--backupStorageType | String | Yes | The type of the backup storage. Valid values: BACKUP_STORAGE_FILE, BACKUP_STORAGE_OSS, BACKUP_STORAGE_COS, and BACKUP_STORAGE_S3. |
| |--storageUrl | String | Yes | The storage directory. Specify a directory without any protocol name, for example, /obbackup/ or osstest/backup. |
| |--ossAccessKey | Object | No | The OSS information. This parameter is valid only when backupStorageType is set to BACKUP_STORAGE_OSS. |
| |--endpoint | String | Yes | The access domain name. |
| |--accessKeyId | String | Yes | The AccessKey ID. |
| |--accessKeySecret | String | Yes | The AccessKey secret. |
| |--cosAccessKey | Object | No | The COS information. This parameter is valid only when backupStorageType is set to BACKUP_STORAGE_COS. |
| |--endpoint | String | Yes | The access domain name. |
| |--accessKeyId | String | Yes | The AccessKey ID. |
| |--accessKeySecret | String | Yes | The AccessKey secret. |
| |--appId | String | Yes | The ID of the application. |
| |--s3AccessKey | Object | No | The S3 information. This parameter is required only when backupStorageType=BACKUP_STORAGE_S3. |
| |--endpoint | String | Yes | The endpoint. |
| |--accessKeyId | String | Yes | The AccessKey ID. |
| |--accessKeySecret | String | Yes | The AccessKey secret. |
| |--region | String | Yes | The region. |
| |--alarmStoragePercentageThreshold | Long | Yes | The threshold for backup storage capacity alerts. Set this parameter to a percentage value. |
| storageId | Long | No | The ID of the storage configuration. |
| serviceType | String | No | The service type. Valid values: BACKUP_RESTORE_SERVICE (for logical backup recovery), OB_CLUSTER (for physical backup recovery), and OTHERS. |
| serviceId | Long | No | The ID of the service. * If the service type is BACKUP_RESTORE_SERVICE, this parameter indicates the backup and recovery service ID. * If the service type is OB_CLUSTER, this parameter indicates the cluster ID. |
| serviceName | String | No | The name of the service. * If the service type is BACKUP_RESTORE_SERVICE, this parameter indicates the name of the backup and recovery service. * If the service type is OB_CLUSTER, this parameter indicates the cluster name. |
| hostIdList | Array | No | The list of host IDs for global data recovery. * If the service type is BACKUP_RESTORE_SERVICE, this parameter indicates the list of the backup and recovery host IDs. * If the service type is OB_CLUSTER, this parameter indicates the list of host IDs in the cluster. |
Data structure of obSecondaryBackupConfig
Parameter |
Type |
Required |
Description |
|---|---|---|---|
| scheduleConfig | Object | Yes | The secondary backup scheduling configuration. |
| |--dataBackupScheduleEnabled | Boolean | Yes | Specifies whether to enable secondary data backup. |
| |--logBackupScheduleEnabled | Boolean | Yes | Specifies whether to enable secondary log backup. |
| |--logSecondaryBackupPeriod | String | Yes | The scheduling cycle for secondary log backup. Currently, only ONCE_A_DAY is supported. |
| storageConfig | Object | Yes | The storage configuration. For more information, see Data structure of obBackupServiceStorageConfig . |
Response parameters
Parameter |
Type |
Description |
|---|---|---|
| data | Object | The common response parameters for backup objects. For more information, see Data structure of BackupCommonResponse . |
| successful | Boolean | Indicates whether the request was successful. |
| timestamp | Datetime | The timestamp when the server completed the request. |
| duration | Integer | The time taken by the server to process the request, in milliseconds. |
| status | Integer | An HTTP status code. |
| traceId | String | The trace ID of the request. This trace ID is used for troubleshooting. |
| server | String | The address of the application server that responded to the request. |
Data structure of BackupCommonResponse
Parameter |
Type |
Description |
|---|---|---|
| obBackupTaskType | String | The backup operation type, for example, CREATE_BACKUP_STRATEGY. |
| backupObjectOpsResultList | Array | The operation result set of the backup object. |
| |--obBackupObjectList | Array | The list of information returned for the backup object. |
| |--clusterId | Long | The ID of the cluster. |
| |--tenantId | Long | The ID of the tenant. |
| |--backupDimension | String | The backup dimension. Valid values: * CLUSTER * TENANT CLUSTER represents cluster backup and TENANT represents tenant backup. Tenant backup is not supported. |
| |--beSuccessful | Boolean | Indicates whether the operation was successful. |
| |--taskIdList | Array | The list of task numbers returned for asynchronous tasks. |
| |--errorCode | Object | The error code. |
| |--hint | String | The prompt information. |
Examples
Sample request
{
"backupMode": "PHYSICAL_BACKUP",
"obSecondaryBackupConfig": {
"storageConfig": {
"configName": "nfs0907_1451",
"obBackupStorageBaseInfo": {
"backupStorageType": "BACKUP_STORAGE_FILE",
"storageUrl": "/obbackup/backup_backup"
},
"alarmStoragePercentageThreshold": 80
},
"scheduleConfig": {
"logSecondaryBackupPeriod": "ONCE_AN_HOUR",
"logBackupScheduleEnabled": true,
"dataBackupScheduleEnabled":true
}
},
"obBackupThresholdConfig": {
"dataBackupTimeoutMinutes": 7,
"logBackupDelaySeconds": 300,
"noSuccessfulDataBackupAlarmDays": 2
},
"secondaryBackupEnabled": true,
"obBackupObjectList": [
{
"clusterId": 1000005,
"backupDimension": "CLUSTER"
}
],
"obBackupScheduleConfig": {
"dayAndDataBackupModelMap": {
"2": "FULL_BACKUP",
"4": "FULL_BACKUP",
"6": "FULL_BACKUP"
},
"startLogBackup": true,
"backupScheduleMode": "WEEK",
"backupScheduleTime": "02:00:00.000+08:00"
},
"obBackupServiceStorageConfig": {
"configName": "nfs0907_1452",
"obBackupStorageBaseInfo": {
"backupStorageType": "BACKUP_STORAGE_FILE",
"storageUrl": "/obbackup/"
},
"alarmStoragePercentageThreshold": 80
}
}
Response example
{
"data": {
"backupObjectOpsResultList": [
{
"beSuccessful": true,
"obBackupObjectList": [
{
"backupDimension": "CLUSTER",
"clusterId": 1000005
}
],
"taskIdList": [
3000041
]
}
],
"obBackupTaskType": "CREATE_BACKUP_STRATEGY"
},
"duration": 51,
"server": "a83ad33525",
"status": 200,
"successful": true,
"timestamp": "2021-09-07T14:51:41.135+08:00",
"traceId": "5962f337662d4043"
}
