Help Center/ Cloud Search Service/ API Reference/ API V1/ Snapshot Management/ Enabling or Modifying the Cluster Snapshot Function
Updated on 2025-11-17 GMT+08:00

Enabling or Modifying the Cluster Snapshot Function

Function

This API is used to enable or modify the cluster snapshot function. Cluster snapshots enhance data protection and restoration capabilities for clusters. By storing a snapshot in an OBS bucket, you save a point-in-time copy of the cluster's data. By restoring this snapshot, you can restore the cluster to a previous state.

When enabling or modifying the cluster snapshot function, you can enable or disable automatic snapshot creation.

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:

Cluster ID. 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 that stores snapshots.

Constraints:

  • The storage class must be Standard.

  • The region must be the same as the region where the cluster is located.

Value range:

N/A

Default value:

N/A

agency

Yes

String

Definition:

Agency name. Select an IAM agency to grant the current account the permission to access and use OBS. To store snapshots to an OBS bucket, you must have the required OBS access permissions.

Constraints:

The agency name can contain only letters (case-sensitive), digits, underscores (_), and hyphens (-). Otherwise, the backup will fail.

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

  • 0

  • -1

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).

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

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

  • 0

  • -1

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).

Setting this parameter to 0mb, 0, -1 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.

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 automatic snapshot creation.

Constraints:

N/A

Value range:

  • true: Enable automatic snapshot creation.

  • false: Disable automatic snapshot creation.

Default value:

false

indices

No

String

Definition:

Name of the index to be backed up.

  • You can specify indexes you want to back up. To specify multiple indexes, use commas (,) to separate them, for example, index1,index2,index3.

  • You can use an asterisk () to match multiple indexes. For example, index indicates that all indexes with the prefix index will be restored.

Constraints:

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

Value range:

The value can contain 0 to 1,024 characters. It cannot contain uppercase letters, spaces, or the following special characters: "<|>/?

Default value:

The default value is empty, indicating that all indexes will be backed up.

prefix

No

String

Definition:

Prefix of the name of an automatically created snapshot. A snapshot name consists of the snapshot name prefix and timestamp, for example, snapshot-1566921603720.

Constraints:

This parameter is mandatory when enable is set to true.

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

period

No

String

Definition:

Time when a snapshot is created every day.

Constraints:

NOTE:
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.

Value range:

Snapshots can only be created on the hour. The time format is the time followed by the time zone, specifically, HH:mm z. In the format, 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.

Default value:

00:00 GMT+08:00

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:

  • This parameter is mandatory when enable is set to true.

  • 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.

Value range:

1–90

Default value:

N/A

frequency

No

String

Definition:

Frequency of automatically creating snapshots.

Constraints:

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.

Value range:

  • HOUR: Execute once every hour on the hour.

  • DAY: Execute once every day.

  • SUN, MON, TUE, WED, THU, FRI, and SAT: Execute the task at the specified day of every week. For example, SUN indicates that the task is executed once every Sunday.

Default value:

DAY

delete_auto

No

String

Definition:

Whether to clear all the automatically created snapshots when disabling automatic snapshot creation.

Constraints:

This parameter takes effect only when enable is set to false.

Value range:

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

false: Do not delete snapshots that were automatically created.

Default value:

false

Response Parameters

Status code: 200

Request succeeded.

None

Example Requests

Enable the snapshot function but do not enable automatic snapshot creation.

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 but do not enable automatic snapshot creation.

 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
54
55
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.withMaxRestoreBytesPerSeconds("0");
        body.withMaxSnapshotBytesPerSeconds("0");
        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 but do not enable automatic snapshot creation.

 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
# 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(
            max_restore_bytes_per_seconds="0",
            max_snapshot_bytes_per_seconds="0",
            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 but do not enable automatic snapshot creation.

 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
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}"
	maxRestoreBytesPerSecondsUpdateSnapshotSettingReq:= "0"
	maxSnapshotBytesPerSecondsUpdateSnapshotSettingReq:= "0"
	basePathUpdateSnapshotSettingReq:= "css_repository/Es-name"
	request.Body = &model.UpdateSnapshotSettingReq{
		MaxRestoreBytesPerSeconds: &maxRestoreBytesPerSecondsUpdateSnapshotSettingReq,
		MaxSnapshotBytesPerSeconds: &maxSnapshotBytesPerSecondsUpdateSnapshotSettingReq,
		BasePath: &basePathUpdateSnapshotSettingReq,
		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.