ElasticDump ile Index Backup/Restore İşlemi

Merhaba, bu yazıda ElasticDump tool’u ile bir Elasticsearch DB’sinden diğer Elasticsearch DB’sine Index migration işleminden bahsedeceğim.
Not: Eğer local’inizden Elasticsearch DB’lerine erişiminiz var ise bu yüklemeleri local’inizde gerçekleştirebilirsiniz.
İlk olarak repo’muzu update edip, ElasticDump tool’u için gereken paketleri install ediyoruz.
|
1 2 |
sudo apt-get update sudo apt-get install curl jq npm |
İlgili paketler kurulduktan sonra, npm paket yöneticisini kullanarak ElasticDump tool’umuzu install ediyoruz.
|
1 |
sudo npm install elasticdump --global |
Daha sonra aşağıdaki komut ile Index backup işlemimizi başlatıyoruz.
|
1 |
elasticdump --input=http://192.168.1.2:9200/IndexName --output=/tmp/IndexNameBackup.json --type=data |
Not: Eğer Elasticsearch DB’lerinizde authentication kullanıyorsanız aşağıdaki komut ile Index backup işleminizi başlatmanız gerekmektedir.
|
1 |
elasticdump --input=http://user:[email protected]:9200/IndexName --output=/tmp/IndexNameBackup.json --type=data |
Output;
|
1 2 3 4 5 6 |
Sat, 20 Mar 2021 12:28:27 GMT | starting dump Sat, 20 Mar 2021 12:28:27 GMT | got 100 objects from source elasticsearch (offset: 0) Sat, 20 Mar 2021 12:28:27 GMT | sent 100 objects to destination file, wrote 100 Sat, 20 Mar 2021 12:28:28 GMT | got 100 objects from source elasticsearch (offset: 100) Sat, 20 Mar 2021 12:28:28 GMT | sent 100 objects to destination file, wrote 100 Sat, 20 Mar 2021 12:28:29 GMT | dump complete |
Aşağıdaki komut ile, backup dosyamızda oluşan bilgilerin bir kısmını check edelim.
|
1 |
tail -50f /tmp/IndexNameBackup.json | jq |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
{ "_index": "IndexName", "_type": "_doc", "_id": "ortQepLV4ADW_poLfOgj", "_score": 1, "_source": { "username": "nuri.gundogan", "name": "Nuri Gündoğan", "age": "24" } } { "_index": "accounts", "_type": "_doc", "_id": "ortGepLV4ADW_kMrTUsm", "_score": 1, "_source": { "username": "osman.osmanoglu", "name": "Osman Osmanoğlu", "age": "40" } } |
Son olarak, /tmp/IndexNameBackup.json dosyamızı yeni Elasticsearch DB’mize restore ediyoruz.
|
1 |
elasticdump --input=/tmp/IndexNameBackup.json --output=http://192.168.1.3:9200/IndexName --type=data |
Output;
|
1 2 3 4 5 6 |
Sat, 20 Mar 2021 12:41:57 GMT | starting dump Sat, 20 Mar 2021 12:41:57 GMT | got 100 objects from source file (offset: 0) Sat, 20 Mar 2021 12:41:59 GMT | sent 100 objects to destination elasticsearch, wrote 100 Sat, 20 Mar 2021 12:41:59 GMT | got 100 objects from source file (offset: 100) Sat, 20 Mar 2021 12:42:00 GMT | sent 100 objects to destination elasticsearch, wrote 100 Sat, 20 Mar 2021 12:42:01 GMT | dump complete |
Umarım faydalı bir anlatım olmuştur. Bir sonraki yazıda görüşmek üzere…