---
title: Elasticsearch migration
tags: Elasticsearch
description: View the slide with "Slide Mode".
---
# Elasticsearch migration
:::danger
在查詢官方資料時,切記要選取elasticsrarch<font color=red>版本</font>
:::
[Documentation](https://www.elastic.co/guide/en/cloud/current/ec-migrate-data.html#ec-index-source)
<!-- Put the link to this slide here so people can follow -->
## <font color=red>如何複製整個叢集</font>
[官方文件 Back up a cluster](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/backup-cluster.html)
To have a complete backup for your cluster:
1. Back up the data [筆記](https://hackmd.io/YnJ_8ngLTKGG19niDauKzg?view)
>[name=昱齊]也就是 snapshot
2. Back up the cluster configuration [筆記](https://hackmd.io/8TtSGQvRSJmifHoNgx0FGg?view)
3. Back up the security configuration(為X-pack功能) [筆記](https://hackmd.io/h3F240EvSsaqeOEQkX-mDA)
To restore your cluster from a backup:
1. Restore the data
2. Restore the security configuration
>[name=昱齊]將備份的`.security-7`取代掉新的cluster的`.security-7`
## 三種搬移<font color=red>資料</font>的作法
>1. Index your data from the original source, which is the simplest method and provides the greatest flexibility for the Elasticsearch version and ingestion method.
>2. Reindex from a remote cluster, which rebuilds the index from scratch.
>3. Restore from a snapshot, which copies the existing indices.
:::success
1. 從原始資料重弄
2. Reindex 從現有es
3. Restore 從snpashot
:::
| | 原始資料 | Reindex | Snapshot |
|--------| -------- | -------- | -------- |
|換elasticsearh版本 | v | x |x |
|有離線資料,隨時可重啟叢集 | v | x | :heavy_check_mark: |
:::warning
- Reindex提醒
1. Before you migrate your Elasticsearch data, define your <font color=red>index mappings</font> on the new cluster. Index mappings are unable to migrate during reindex operations.
2. Reindexing essentially rebuilds the index from scratch and it can be more <font color=red>resource intensive</font> to run.
:::
> [name=昱齊]那snapshot是否也要手動備份mapping
## Rolling upgrade
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/rolling-upgrades.html)
### 事前準備
#### Rolling upgrades are supported:
1. Between minor versions
1. From 5.6 to 6.8
1. From 6.8 to 7.3.2
- Upgrading directly to 7.3.2 from 6.7 or earlier requires a <font color=blue>full cluster restart.</font>

---
### `elasticsearch-migrate`
> The elasticsearch-migrate command migrates existing file-based users and roles to the native realm. From 5.0 onward, you should use the native realm to manage roles and local users.
[elasticsearch-migrate](https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-tool.html)