The auto snapshot feature allows you to specify the snapshot creation interval and time. After you specify them, the system automatically creates snapshots to ensure data security. You can then use the auto restoration feature to quickly restore data to the original Alibaba Cloud Elasticsearch cluster from the automatically created snapshots. This topic describes the auto snapshot and auto restoration features of Alibaba Cloud Elasticsearch.

Prerequisites

An Alibaba Cloud Elasticsearch cluster is created. For more information, see Create an Elasticsearch cluster.

Enable auto snapshot

  1. Log on to the Alibaba Cloud Elasticsearch console.
  2. In the top navigation bar, select the region where your Alibaba Cloud Elasticsearch cluster resides.
  3. Find the target cluster and click its ID.
  4. In the left-side navigation pane, click Snapshots.
  5. In the Snapshots (Free Trial) section, turn on the Auto Snapshot switch.
  6. Click Modify Configuration on the right side of Snapshots (Free Trial).
    Notice To ensure system security, the value of Auto Snapshot Period for Elasticsearch clusters of the Advanced Edition is generated by the system and cannot be changed.
  7. In the Auto Snapshot Configuration pane, set Frequency.
    Set a snapshot creation interval
    Frequency Description
    Every 30 Minutes The system creates snapshots at 30-minute intervals.
    Daily The system creates snapshots every day. You can customize the snapshot creation time.
    Custom The system creates snapshots based on the interval you specify.
    Notice The system uses the system time of the region where your Elasticsearch cluster resides to create snapshots.
  8. Click Save.

Restore data from snapshots

If you enable the auto snapshot feature for an Elasticsearch cluster, the system creates snapshots for this cluster based on the snapshot creation interval that you specified. You can call the snapshot operation to restore data to the cluster from the created snapshots.
Note
  • The first snapshot is a full copy of the data in an Elasticsearch cluster. Subsequent snapshots only store incremental data. Therefore, it requires longer time to create the first snapshot than a subsequent snapshot.
  • Snapshots store only index data. The following information of your Elasticsearch cluster is not stored in snapshots: monitoring data (such as indexes with the prefix .monitoring or .security_audit), metadata, translog files, configurations, software packages, built-in and custom plug-ins, and logs.
  • The system can restore data from snapshots only to the original Elasticsearch cluster.
  • An auto snapshot repository is created when the first snapshot is created.
  1. Log on to the Kibana console of your Elasticsearch cluster.
    For more information, see Log on to the Kibana console.
  2. In the left-side navigation pane, click Dev Tools. On the Console tab of the page that appears, run a command to perform a specific operation.
    • Query all snapshot repositories

      Run the GET _snapshot command to query all snapshot repositories.

      If the command is executed successfully, the following result is returned:
      {
        "aliyun_auto_snapshot": {
          "type": "oss",
          "settings": {
            "compress": "true",
            "base_path": "xxxx",
            "endpoint": "xxxx"
          }
        }
      }
      Parameter Description
      aliyun_auto_snapshot The name of the repository.
      type The storage where snapshots are stored. The value oss indicates that snapshots are stored in Alibaba Cloud Object Storage Service (OSS).
      compress Indicates whether compression is used. The value true indicates that the metadata of indexes is compressed during snapshot creation.
      base_path The location of snapshots in OSS.
      endpoint The endpoint of the OSS bucket.
    • Query all snapshots

      Run the GET _snapshot/aliyun_auto_snapshot/_all command to query all snapshots in the aliyun_auto_snapshot repository.

      If the command is executed successfully, the following result is returned:
      {
        "snapshots": [ 
          {
            "snapshot": "es-cn-abcdefghij****_20180627091600",
            "uuid": "MMRniVLPRAiawSCm8D****",
            "version_id": 5050399,
            "version": "5.5.3",
            "indices": [
              "index_1",
              ".security",
              ".kibana"
            ],
            "state": "SUCCESS",
            "start_time": "2018-06-27T01:16:01.009Z",
            "start_time_in_millis": 1530062161009,
            "end_time": "2018-06-27T01:16:05.632Z",
            "end_time_in_millis": 1530062165632,
            "duration_in_millis": 4623,
            "failures": [],
            "shards": {
              "total": 12,
              "failed": 0,
              "successful": 12
            }
          }
        ]
      }
      Notice The system uses the system time of the current region to create snapshots. However, the time in the returned result is in UTC, which indicates a time zone difference. You can convert the time in the returned result based on the time zone difference. For example, the time zone difference of the China (Beijing) region is 8 hours. In this case, the system time in the China (Beijing) region is UTC+0080.
      The auto snapshot feature also supports the following default parameters that are not displayed.
      Parameter Description
      max_snapshot_bytes_per_sec:40mb The maximum speed for snapshot creation on a single node is 40 MB/s.
      max_restore_bytes_per_sec:40mb The maximum speed for data restoration on a single node is 40 MB/s.
      chunk_size: Max 1Gb During snapshot creation, a large index is divided into multiple parts. The maximum size of each part is 1 GB.
    • Restore indexes from a snapshot
      You can call the _restore operation to restore indexes from snapshots.
      • Run the following command to restore all indexes from a specified snapshot that is stored in the aliyun_auto_snapshot repository. The restoration task is executed at the backend.
        POST _snapshot/aliyun_auto_snapshot/<snapshot>/_restore

        Replace <snapshot> with the name of the specified snapshot, such as es-cn-abcdefghij****_20180627091600.

      • Run the following command to restore all indexes from a specified snapshot that is stored in the aliyun_auto_snapshot repository. Then, wait until the restoration task is complete.
        The _restore operation runs restoration tasks asynchronously. An Alibaba Cloud Elasticsearch cluster will immediately return a response if the _restore operation is executable. The restoration task is executed at the backend. You can set the wait_for_completion parameter to enable the cluster to return a response only after the restoration task is complete.
        POST _snapshot/aliyun_auto_snapshot/<snapshot>/_restore?wait_for_completion=true

        Replace <snapshot> with the name of the specified snapshot, such as es-cn-abcdefghij****_20180627091600.

      • Run the following command to restore specified indexes from a specific snapshot that is stored in the aliyun_auto_snapshot repository, and rename the restored indexes. The restoration task is executed at the backend.
        POST _snapshot/aliyun_auto_snapshot/<snapshot>/_restore
        {
        "indices": "index_1",
        "rename_pattern": "index_(.+)",
        "rename_replacement": "restored_index_$1"
        }
        Parameter Description
        <snapshot> Replace it with the name of the specified snapshot, such as es-cn-abcdefghijklmn_20180627091600.
        indices The name of the index you want to restore.
        rename_pattern Optional. This parameter specifies the regular expression that is used to match the name of the index you want to restore.
        rename_replacement Optional. This parameter specifies the regular expression that is used to rename a matched index.