diff --git a/.gitignore b/.gitignore index d8b846b..2db39d3 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,9 @@ local.properties # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 .idea/ +*.iws +*.iml +*.ipr # User-specific stuff .idea/**/workspace.xml diff --git a/README.md b/README.md index 4ee8ce6..e853c0b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,19 @@ $ mvn clean install $ ./run.sh ``` +## Migrate elasticsearch data + +To migrate the collected data from our local elasticsearch to the cloud elasticsearch we can use the following command: +``` +$ ./migrate-elasticsearch-data.sh localIndex cloudElasticPath +``` +As first parameter we need to insert the local index to migrate and as second parameter the elastic cloud index path adding the user and password. + +Example: +``` +$ ./migrate-elasticsearch-data.sh sampleIndex https://user:password@elasticCloudHost/sampleIndex +``` + ## Built With * [Spring Framework](https://spring.io/) - The framework used diff --git a/migrate-elasticsearch-data.sh b/migrate-elasticsearch-data.sh new file mode 100644 index 0000000..c426a60 --- /dev/null +++ b/migrate-elasticsearch-data.sh @@ -0,0 +1,25 @@ +#!/bin/bash +localElastic=$(docker ps | grep 'docker.elastic.co/elasticsearch/elasticsearch' | awk '{print $1}') + +if [[ "$localElastic" != "" ]] +then + from="http://elasticsearch:9200/$1" + to=$2 + echo "Moving data from: $from to $to" + + docker run --name=elasticsearch-dump --network=docker_elk --link=${localElastic}:elasticsearch taskrabbit/elasticsearch-dump --input=${from} \ + --output=${to} \ + --type=data + + echo "Stopped docker container:" $(docker stop elasticsearch-dump) + echo "Removed docker container:" $(docker rm elasticsearch-dump) + + echo "**********************************************************************************" + echo "******************** Imported data to cloud elasticsearch! :) ********************" + echo "**********************************************************************************" + +else + echo "**********************************************************************************" + echo "************************** Local elastic is not running **************************" + echo "**********************************************************************************" +fi \ No newline at end of file