Help Center/ Cloud Search Service/ API Reference/ API V1/ Snapshot Management/ Modifying Basic Configurations of a Cluster Snapshot
Updated on 2025-08-15 GMT+08:00

Modifying Basic Configurations of a Cluster Snapshot

Function

This API is used to modify the basic configurations for a cluster snapshot, including OBS buckets and IAM agency.

You can also use this API to enable the snapshot function.

Calling Method

For details, see Calling APIs.

URI

POST /v1.0/{project_id}/clusters/{cluster_id}/index_snapshot/setting

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

Project ID. For details about how to obtain the project ID and name, see Obtaining the Project ID and Name.

Constraints:

N/A

Value range:

Project ID of the account.

Default value:

N/A

cluster_id

Yes

String

Definition:

ID of the target cluster For details about how to obtain the cluster ID, see Obtaining the Cluster ID.

Constraints:

N/A

Value range:

Cluster ID.

Default value:

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

bucket

Yes

String

Definition:

Name of the OBS bucket used for backup.

Constraints:

  • Storage class: standard.

  • Region: the same as that of the cluster.

Value range:

N/A

Default value:

N/A

agency

Yes

String

Definition:

Agency name. You can create an agency to allow CSS to call other cloud services.

Constraints:

The value can contain only letters (a-z and A-Z), digits (0-9), hyphens (-), and underscores (_). It cannot contain Chinese characters or other special characters.

Value range:

N/A

Default value:

N/A

base_path

No

String

Definition:

Storage path of the snapshot in the OBS bucket.

Constraints:

N/A

Value range:

  • The backup path cannot contain the following characters: \:*?"<>|'{}. Additionally, it cannot:

  • Start with a slash (/).

  • Start or end with a period (.).

  • Contain more than two consecutive slashes (/) or periods (.).

  • Exceed 512 characters.

Default value:

N/A

max_snapshot_bytes_per_seconds

No

String

Definition:

This parameter sets the maximum backup speed per node (bytes per second). When it is exceeded, flow control is triggered to prevent excessive resource usage and ensure system stability. The actual backup speed may not reach the configured value, as it depends on many factors, such as OBS performance and disk I/O.

Constraints:

N/A

Value range:

The following values and formats are allowed:

  • Number + Unit

The number ranges from 0 to 9999.

The unit can be k, kb, m, mb, g, gb, t, tb, p, pb, or b (case-insensitive).

0mb means there is no speed limit. An overly high backup speed may lead to excessive resource usage, which may impact system stability. Therefore, set this parameter carefully.

  • 0

There is no speed limit. An overly high backup speed may lead to excessive resource usage, which may impact system stability. Therefore, set this parameter carefully.

  • -1

There is no speed limit. An overly high backup speed may lead to excessive resource usage, which may impact system stability. Therefore, set this parameter carefully.

Default value:

The default value is 40 MB. If this parameter is left blank, the default value is used.

max_restore_bytes_per_seconds

No

String

Definition:

This parameter sets the maximum recovery speed per node (bytes per second). When it is exceeded, flow control is triggered to prevent excessive resource usage and ensure system stability. The actual recovery speed may not reach the configured value, as it depends on many factors, such as OBS performance and disk I/O.

Constraints:

For OpenSearch clusters and Elasticsearch clusters later than 7.6.2, the recovery speed is also limited by the indices.recovery.max_bytes_per_sec parameter. If Maximum recovery speed (per second) is lower than indices.recovery.max_bytes_per_sec, flow control is triggered when the former is reached. If Maximum recovery speed (per second) is higher than indices.recovery.max_bytes_per_sec, flow control is triggered when the latter is reached.

Value range:

The following values and formats are allowed:

  • Number + Unit

The number ranges from 0 to 9999.

The unit can be k, kb, m, mb, g, gb, t, tb, p, pb, or b (case-insensitive).

0mb means there is no speed limit. (However, for OpenSearch clusters and Elasticsearch clusters later than 7.6.2, the recovery speed is also limited by the indices.recovery.max_bytes_per_sec parameter.) An overly high recovery speed may lead to excessive resource usage, which may impact system stability. Therefore, set this parameter carefully.

  • 0

There is no speed limit. (However, for OpenSearch clusters and Elasticsearch clusters later than 7.6.2, the recovery speed is also limited by the indices.recovery.max_bytes_per_sec parameter.) An overly high recovery speed may lead to excessive resource usage, which may impact system stability. Therefore, set this parameter carefully.

  • -1

There is no speed limit. (However, for OpenSearch clusters and Elasticsearch clusters later than 7.6.2, the recovery speed is also limited by the indices.recovery.max_bytes_per_sec parameter.) An overly high recovery speed may lead to excessive resource usage, which may impact system stability. Therefore, set this parameter carefully.

Default value:

For Elasticsearch clusters of 7.6.2 or earlier, the default setting is 40mb.

For OpenSearch clusters and Elasticsearch clusters later than 7.6.2, the default setting is no limit, but the recovery speed is still limited by the indices.recovery.max_bytes_per_sec parameter.

If this parameter is left blank, the default setting is used.

enable

No

String

Definition:

Whether to enable the automatic snapshot creation policy.

Constraints:

N/A

Value range:

true: The automatic snapshot creation policy is enabled.

false: disabled.

Default value:

N/A

indices

No

String

Definition:

Name of the index to be backed up. The value * indicates all indexes.

Constraints:

This parameter is valid only when enable is set to true.

Value range:

N/A

Default value:

N/A

prefix

No

String

Definition:

Prefix of a snapshot that is automatically created, which is manually entered.

Constraints:

N/A

Value range:

Enter up to 32 characters and start with a lowercase letter. Lowercase letters, digits, hyphens (-), and underscores (_) are allowed.

Default value:

N/A

This parameter is mandatory when enable is set to true.

period

No

String

Definition:

Time when a snapshot is generated every day. Snapshots can only be generated on the hour. The format is HH:mm z: HH:mm refers to the hour time and z refers to the time zone. For example, 00:00 GMT+08:00 and 01:00 GMT+08:00.

Constraints:

N/A

Value range:

N/A

Default value:

00:00 GMT+08:00

The default value is 00:00 GMT+08:00. When frequency is set to HOUR, you do not need to specify period. By default, snapshot creation starts from the next hour after the settings are successful. This parameter is mandatory when enable is set to true.

keepday

No

Integer

Definition:

Customize the number of snapshots to be retained. Expired snapshots will be automatically deleted on the half hour. The deletion policy applies only to automated snapshots that are executed at the same frequency as the current automatic snapshot creation policy.

Constraints:

N/A

Value range:

1–90

Default value:

N/A

This parameter is mandatory when enable is set to true.

frequency

No

String

Definition:

Frequency of automatically creating snapshots.

Constraints:

N/A

Value range:

N/A

Default value:

DAY

The default value is DAY. When the value is HOUR, the task is executed every hour. When the value is DAY, the scheduled task is executed every day. When the parameter is set to SUN, MON, TUE, WED, THU, FRI or SAT, the scheduled task is executed at the specified day of every week. The number of retained snapshots depends on the execution frequency and indexes set in the automatic snapshot creation policy. If the execution interval is short or the index data volume is large, the number of retained automatic snapshots may not reach the preset value. Set this value based on actual conditions.

delete_auto

No

String

Definition:

Whether to clear all the automatically created snapshots when the automatic snapshot creation policy is disabled.

Constraints:

N/A

Value range:

true: Delete all automatically created snapshots when an automatic snapshot creation policy is disabled.

false: Retain automatically created snapshots when an automatic snapshot creation policy is disabled.

Default value:

false

Response Parameters

Status code: 200

Request succeeded.

None

Example Requests

Enable the snapshot function.

POST https://{Endpoint}/v1.0/{project_id}/clusters/4f3deec3-efa8-4598-bf91-560aad1377a3/index_snapshot/setting

{
  "bucket" : "test-bucket",
  "agency" : "usearch",
  "base_path" : "css_repository/Es-name",
  "max_snapshot_bytes_per_seconds" : 0,
  "max_restore_bytes_per_seconds" : 0
}

Example Responses

None

SDK Sample Code

The SDK sample code is as follows.

Java

Enable the snapshot function.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.css.v1.region.CssRegion;
import com.huaweicloud.sdk.css.v1.*;
import com.huaweicloud.sdk.css.v1.model.*;


public class UpdateSnapshotSettingSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        CssClient client = CssClient.newBuilder()
                .withCredential(auth)
                .withRegion(CssRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateSnapshotSettingRequest request = new UpdateSnapshotSettingRequest();
        request.withClusterId("{cluster_id}");
        UpdateSnapshotSettingReq body = new UpdateSnapshotSettingReq();
        body.withBasePath("css_repository/Es-name");
        body.withAgency("usearch");
        body.withBucket("test-bucket");
        request.withBody(body);
        try {
            UpdateSnapshotSettingResponse response = client.updateSnapshotSetting(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

Enable the snapshot function.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcss.v1.region.css_region import CssRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcss.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = CssClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CssRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateSnapshotSettingRequest()
        request.cluster_id = "{cluster_id}"
        request.body = UpdateSnapshotSettingReq(
            base_path="css_repository/Es-name",
            agency="usearch",
            bucket="test-bucket"
        )
        response = client.update_snapshot_setting(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

Enable the snapshot function.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    css "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/css/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/css/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/css/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := css.NewCssClient(
        css.CssClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdateSnapshotSettingRequest{}
	request.ClusterId = "{cluster_id}"
	request.Body = &model.UpdateSnapshotSettingReq{
		BasePath: "css_repository/Es-name",
		Agency: "usearch",
		Bucket: "test-bucket",
	}
	response, err := client.UpdateSnapshotSetting(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Request succeeded.

406

The server could not fulfill the request according to the content characteristics of the request.

412

The server did not meet one of the preconditions contained in the request.

504

A gateway timeout error occurred.

Error Codes

See Error Codes.