Description
You can call this operation to create a backup strategy for a cluster, set the cycle, time, and storage address for backup scheduling, and set the expired data cleanup and alert thresholds.
Call description
Prerequisites
You have the Create permission on cluster backup and recovery.
You have passed the authentication for the OCP application service.
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 you want to create a backup strategy. |
Request parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| backupMode | String | Yes | LOGICAL_BACKUP | The backup mode. Valid values: * LOGICAL_BACKUP * PHYSICAL_BACKUP |
| obBackupScheduleConfig | Object | Yes | N/A | The backup scheduling configuration. For more information, see Data structure of obBackupScheduleConfig . |
| obBackupThresholdConfig | Object | Yes | N/A | The threshold for backup alerts. For more information, see Data structure of obBackupThresholdConfig . |
| obBackupServiceStorageConfig | Object | Yes | N/A | The backup storage configuration. For more information, see Data structure of obBackupServiceStorageConfig . |
| secondaryBackupEnabled | Boolean | No | False | Specifies whether to enable secondary backup. Default value: false. Only OceanBase Database V2.2.77 and later support secondary backup. |
| obSecondaryBackupConfig | Object | No | N/A | 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 scheduling cycle. Valid values: WEEK and MONTH. |
| backupScheduleEnabled | Boolean | Yes | Specifies whether to enable backup. |
| backupScheduleTime | OffsetTime | Yes | The scheduled backup time, for example, "02:00:00.000+08:00". |
| dayAndDataBackupModelMap | Map | Yes | The backup schedule and data backup method, for example, { "2": "FULL_BACKUP", "4": "FULL_BACKUP", "6": "INCREMENTAL_BACKUP" } The settings specify full data backup on Tuesday and Thursday and incremental data backup on Saturday. |
| startLogBackup | Boolean | Yes | Specifies whether to start log backup at the same time. This parameter is generally set to true. |
| cleanEnabled | Boolean | No | Specifies whether to enable expired data cleanup. |
| backupDataRetentionDays | Long | No | The number of days for backup data retention. If you set it to 7, the system retains data of the last seven days. This parameter is valid only when cleanEnabled is set to true. |
| cleanScheduleTime | OffsetTime | No | The scheduled time to delete 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 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 storage type. Valid values: BACKUP_STORAGE_FILE, BACKUP_STORAGE_OSS, and BACKUP_STORAGE_COS. |
| |--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. |
| |--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
}
}
Sample response
{
"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"
}