Alibaba Cloud Elasticsearch (ES) provides shared OSS repositories to help you restore data across Elasticsearch instances.

Background information

You can restore an automatically created snapshot in a shared OSS repository of an Elasticsearch instance to another Elasticsearch instance.

For example, you have created two Elasticsearch V6.7.0 instances. Their instance IDs are es-cn-a and es-cn-b. The instance es-cn-a has enabled auto snapshot and automatically created a snapshot. If you want to restore the snapshot of the instance es-cn-a to instance es-cn-b, you must use shared OSS repositories.

Compatibility

  • To use shared OSS repositories to restore a snapshot created on an Elasticsearch instance to another Elasticsearch instance, you must make sure that both instances are created by the same user account and deployed in the same region.
  • In the case of two Elasticsearch instances using two different Elasticsearch versions, the later version can use the repository of the earlier version. The earlier version cannot use the repository of the later version.
    Notice When the later version uses the repository of the earlier version, it may not support the data format of the earlier version. For example, you can restore indexes that contain only one document type from an Elasticsearch V5.5.3 instance to an Elasticsearch V6.7.0 instance. However, if you restore indexes that contain multiple document types from the Elasticsearch V5.5.3 instance to the Elasticsearch V6.7.0 instance, a restore error may occur. This is because Elasticsearch V6.7.0 does not support indexes that contain multiple document types. Therefore, we recommend that you run a test before you restore the data.

Add a shared OSS repository

  1. Log on to the Alibaba Cloud Elasticsearch console, and select Instance ID/Name > Snapshots.
  2. In the Shared OSS Repositories section, click Add Now.
    Add a shared OSS repository
  3. In the Add Shared Repository dialog box, select an Elasticsearch instance. The system then creates a shared repository for the instance.
    Add Shared Repository page
    Notice The selected instance version must be compatible with the current instance version. For more information, see Compatibility.
  4. Click OK.
    After the shared repository is added, the current page shows the instance that owns the repository and the repository status.Shared repository successfully added
    Notice
    • 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 instance or repository does not exist.
    • The system uses your Elasticsearch instance to retrieve the repository list. If the instance is updating its configuration, the instance is not in the Normal state, or the workload of the instance is high, the system may fail to retrieve the repository list. If this error occurs, you can log on to the Kibana console, and send a GET _snapshot request to retrieve the endpoints of all repositories.

Restore an index

A shared OSS repository is only used to share data between two Elasticsearch instances. It cannot help you restore data. If you need to restore index data, send the corresponding API requests from the Kibana console.

For example, send the following request from the Kibana console to restore the index file-2019-08-25 from the instance es-cn-a.

  1. Query information about all snapshots in the repository.
    GET /_cat/snapshots/aliyun_auto_snapshot_from_a? v
    The request returns information about all snapshots in the repository.Information about all snapshots in the repository
  2. According to the returned snapshot information, restore indexes in the snapshot.
    Notice Before you restore an index, you must 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.
    POST _snapshot/aliyun_snapshot_from_es-cn-a/es-cn-a_20190705220000/_restore 
     {"indices": "file-2019-08-25"}
    POST _snapshot/aliyun_snapshot_from_es-cn-a/es-cn-a_20190705220000/_restore
     {"indices": "kibana_sample_data_ecommerce,kibana_sample_data_logs"}