Alibaba Cloud Elasticsearch provides shared OSS repositories. Automatic snapshots are stored in these repositories, which help you restore data to your Elasticsearch clusters based on your needs. For example, you have created two Elasticsearch V6.7.0 clusters es-cn-a and es-cn-b. The auto snapshot feature is enabled for the es-cn-a cluster, and the cluster has automatically created a snapshot. If you want to restore the data in the snapshot to the es-cn-b cluster, specify a shared OSS repository.

Prerequisites

The source and destination Elasticsearch clusters must meet the following requirements:
  • The clusters reside in the same region.
  • The clusters belong to the same account.
  • The version of the source cluster is earlier than or the same as that of the destination cluster.
    Notice
    • An Elasticsearch cluster can only use the repository of an Elasticsearch cluster of the same or an earlier version.
    • However, when the repository of an Elasticsearch cluster is used, its data format may be incompatible. For example, you can restore indexes that contain only one document type to an Elasticsearch V6.7.0 cluster from snapshots in the repository of an Elasticsearch V5.5.3 cluster. However, if you restore indexes that contain multiple document types to the Elasticsearch V6.7.0 cluster from snapshots in the repository of the Elasticsearch V5.5.3 cluster, an error may occur. This is because Elasticsearch V6.7.0 clusters do not support indexes that contain multiple document types.

Add a shared OSS repository

  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 Shared OSS Repositories section, click Add Now.
    Notice If it is not the first time you add a shared OSS repository, click Add Shared Repository.
  6. In the Add Shared Repository dialog box, select an Elasticsearch cluster.
    Notice The selected cluster must meet the preceding requirements.
  7. Click OK.
    After the shared repository is added, the current page shows the cluster that owns the repository and the repository status.Shared repository successfully added

    A shared repository has two states: Active and Inactive. The Active state indicates that the repository is available. The Inactive state indicates that the specified cluster or repository does not exist.

    Notice The system uses your Elasticsearch cluster to retrieve the repository list. If the cluster is updating its configuration, is in an abnormal state, or encounters heavy workloads, the system may fail to retrieve the repository list. If this error occurs, you can log on to the Kibana console and run the GET _snapshot command to retrieve the endpoints of all repositories. For more information, see Log on to the Kibana console.

Restore an index

Shared OSS repositories are only used to share data between Elasticsearch clusters. The system cannot directly restore data for clusters from shared OSS repositories. If you need to restore an index, run a relevant command in the Kibana console of the target Elasticsearch cluster.
Note For more information about how to log on to the Kibana console, see Log on to the Kibana console.

For example, run the following command in the Kibana console to restore the file-2019-08-25 index from the es-cn-a cluster.

  1. Query information about all snapshots in a specific repository.
    GET /_cat/snapshots/aliyun_snapshot_from_es-cn-a?v
    The command returns information about all snapshots in the repository.Information about all snapshots in the repository
    Note aliyun_snapshot_from_es-cn-a is the shared repository added in Add a shared OSS repository.
  2. Based on the returned snapshot information, restore indexes in the snapshot.
    Notice Before you restore an index, make sure that the node to which the index is restored does not have an index with the same name. If the node has an index with the same name, make sure that the index status is close. If the status of the index is open, an error occurs when you restore the index to the node.
    • Restore a single index
      POST _snapshot/aliyun_snapshot_from_es-cn-a/es-cn-a_20190705220000/_restore 
       {"indices": "file-2019-08-25"}
    • Restore multiple indexes
      POST _snapshot/aliyun_snapshot_from_es-cn-a/es-cn-a_20190705220000/_restore
       {"indices": "kibana_sample_data_ecommerce,kibana_sample_data_logs"}