Help Center/ Cloud Search Service/ API Reference/ API V1/ Snapshot Management/ Querying the Automatic Snapshot Creation Policy
Updated on 2025-08-15 GMT+08:00

Querying the Automatic Snapshot Creation Policy

Function

CSS allows you to use snapshots to back up and restore Elasticsearch cluster data. 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. There are two ways to create snapshots to back up a CSS cluster: automatic and manual. This API is used to query the automatic snapshot creation policy.

  • Automatic snapshot creation: Snapshots are automatically created daily or weekly based on a preset time schedule, ensuring ongoing data protection. By configuring an automatic snapshot policy, you reduce manual operations while improving backup reliability and efficiency.

  • Manual snapshot creation: You create snapshots manually for special occasions, for example, prior to a high-risk operation (such as a cluster upgrade). This ensures you can restore data using snapshots in case anything should go wrong. Manual snapshots provide additional flexibility.

Calling Method

For details, see Calling APIs.

URI

GET /v1.0/{project_id}/clusters/{cluster_id}/index_snapshot/policy

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 cluster where snapshots are to be automatically created. 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

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

keepday

Integer

Definition:

Customize the number of snapshots to be retained.

Value range:

N/A

period

String

Definition:

Time when a snapshot is created every day.

Value range:

N/A

prefix

String

Definition:

Snapshot name prefix, which needs to be manually entered.

Value range:

N/A

bucket

String

Definition:

Name of the OBS bucket where snapshots are stored.

Value range:

N/A

basePath

String

Definition:

Storage path of the snapshot in the OBS bucket.

Value range:

N/A

agency

String

Definition:

Agency used to access OBS buckets.

Value range:

N/A

enable

String

Parameter description:

Whether to enable the automatic snapshot creation policy.

Options:

  • true: The automatic snapshot creation policy is enabled.

  • false: The automatic snapshot creation policy is disabled.

frequency

String

Parameter description:

Frequency of automatically creating snapshots.

Options:

  • DAY: days.

  • HOUR: hours.

  • MON: Monday.

  • TUE: Tuesday.

  • WED: Wednesday.

  • THU: Thursday.

  • FRI: Friday.

  • SAT: Saturday.

  • SUN: Sunday.

maxSnapshotBytesPerSeconds

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.

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.

maxRestoreBytesPerSeconds

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.

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.

Example Requests

Query the automatic snapshot creation policy.

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

Example Responses

Status code: 200

Request succeeded.

{
  "keepday" : 2,
  "frequency" : "DAY",
  "period" : "16:00 GMT+08:00",
  "prefix" : "snapshot",
  "bucket" : "es-backup",
  "basePath" : "css_repository/tests",
  "agency" : "usearch",
  "enable" : "true"
}

SDK Sample Code

The SDK sample code is as follows.

Java

 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 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 ShowAutoCreatePolicySolution {

    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();
        ShowAutoCreatePolicyRequest request = new ShowAutoCreatePolicyRequest();
        request.withClusterId("{cluster_id}");
        try {
            ShowAutoCreatePolicyResponse response = client.showAutoCreatePolicy(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

 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
# 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 = ShowAutoCreatePolicyRequest()
        request.cluster_id = "{cluster_id}"
        response = client.show_auto_create_policy(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

 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
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.ShowAutoCreatePolicyRequest{}
	request.ClusterId = "{cluster_id}"
	response, err := client.ShowAutoCreatePolicy(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.

Error Codes

See Error Codes.