Last active
August 7, 2018 16:03
-
-
Save ZedYeung/bb37b9731fd7877bf4a4bdbd94779aec to your computer and use it in GitHub Desktop.
elasticdump.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# npm install elasticdump -g | |
# Copy an index from production to staging with analyzer and mapping: | |
SRC=http://yue.yang:Bgyqhjbf1746@10.100.121.210:9200 | |
DEST=http://yue.yang:Bgyqhjbf1746@35.224.243.158:9200 | |
# INDICES="billing_data_v2-2018.07.20,platform_nlog_v9-2018.07.20,platform_vfw_v1-2018.07.20,platform_cna_v1-2018.07.20" | |
SIZE=10000 | |
LIMIT=10000 | |
INDICES="billing_data_v2-2018.07.19" | |
# only dump data | |
# green open billing_data_v2-2018.07.20 E3k8NSQSRvaHss2AW5DApQ 2 0 196301 0 66.7mb 66.7mb | |
# dump analyzer, mapping, data | |
# green open billing_data_v2-2018.07.21 Ern9tuORTdSjf0tm_9eGqg 2 0 0 0 324b 324b | |
# dump mapping, data | |
# green open billing_data_v2-2018.07.22 vapiRCRqTO604TZteUU2kw 2 0 0 0 324b 324b | |
# string -> text, keyword | |
# green open billing_data_v2-2018.07.19 o6bMjGseQcOrKfrUUvjtJw 2 0 150308 0 53.7mb 53.7mb | |
# could be curl, but still no result found on Kibana | |
# use same mapping | |
# green open billing_data_v2-2018.07.23 KQKeK_KrTxGjZ1Ka7twUGw 2 0 210443 0 75.1mb 75.1mb | |
# ANALYTICS_INDICES="analytics_downtimerpt_v1-2018.07.26,analytics_sla-credit-audit_v1-2018.07.26,analytics_jira_v2-2018.07.26,analytics_replication_v4-2018.07.26,analytics_infrastructure_v7-2018.07.26,analytics_sla-credit-logs_v1-2018.07.26,analytics_sla-event_v1-2018.07.26,analytics_test_v4-2018.07.26" | |
# POST /_aliases | |
# { | |
# "actions" : [ | |
# { | |
# "add" : { | |
# "index" : "billing_data_v2-2018.07.23", | |
# "alias" : { | |
# "all_data-2018.07.23": {}, | |
# "billing_data-2018.07.23": {} | |
# } | |
# } | |
# } | |
# ] | |
# } | |
POST /_aliases | |
{ | |
"actions" : [ | |
{ | |
"add" : { | |
"index" : "billing_data_v2-2018.07.23", | |
"alias" : "all_data-2018.07.23" | |
} | |
} | |
] | |
} | |
IFS="," | |
for INDEX in $INDICES; | |
do | |
echo $INDEX | |
# curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X PUT http://yue.yang:Bgyqhjbf1746@35.224.243.158:9200/camcore_alm_v2-2018.07.31 | |
# curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET $SRC/$INDEX | |
# curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET $DEST/$INDEX | |
curl -u 'yue.yang:Bgyqhjbf1746' -X DELETE http://35.224.243.158:9200/$INDEX | |
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X PUT $DEST/$INDEX | |
# | |
# curl -u 'yue.yang:Bgyqhjbf1746' -X DELETE http://35.224.243.158:9200/${INDEX}_backup | |
# | |
# curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X PUT $DEST/${INDEX}_backup | |
elasticdump \ | |
--input=$SRC/$INDEX \ | |
--output=$DEST/$INDEX \ | |
--type=analyzer | |
elasticdump \ | |
--input=$SRC/$INDEX \ | |
--output=$DEST/$INDEX \ | |
--type=mapping | |
# --size=$SIZE \ | |
# --quiet | |
elasticdump \ | |
--input=$SRC/$INDEX \ | |
--output=$DEST/$INDEX \ | |
--type=data \ | |
--limit=$LIMIT | |
# --size=$SIZE \ | |
# --quiet | |
# curl -u 'yue.yang:Bgyqhjbf1746' -X POST "http://35.224.243.158:9200/_reindex?pretty" -H 'Content-Type: application/json' -d' | |
# | |
# { | |
# "source": { | |
# "index": "billing_data_v2-2018.07.20_backup" | |
# }, | |
# "dest": { | |
# "index": "billing_data-_v2-2018.07.20" | |
# } | |
# } | |
# ' | |
# curl -u 'yue.yang:Bgyqhjbf1746' -X POST "http://35.224.243.158:9200/_reindex?pretty" -H 'Content-Type: application/json' -d' | |
# { | |
# "source": { | |
# "index": "'"${INDEX}_backup"'" | |
# }, | |
# "dest": { | |
# "index": "'"${INDEX}"'" | |
# } | |
# } | |
# ' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment