Created
August 28, 2021 17:22
-
-
Save premchalmeti/1da8095d7e02162c47771bf8942d695a to your computer and use it in GitHub Desktop.
Migrate elasticsearch mapping and data from source to target cluster
This file contains hidden or 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
INDICES = [ | |
"documents_index", | |
"england_geographies" | |
] | |
SRC_HOST = 'src_host' | |
SRC_PORT = 9200 | |
DEST_HOST = 'dest_host' | |
DEST_PORT = 9200 | |
MAPPING_CMD = 'elasticdump --input=http://%(SRC_HOST)s:%(SRC_PORT)s/%(INDEX)s --output=http://%(DEST_HOST)s:%(DEST_PORT)s/%(INDEX)s --type=mapping' | |
DATA_CMD = 'elasticdump --input=http://%(SRC_HOST)s:%(SRC_PORT)s/%(INDEX)s --output=http://%(DEST_HOST)s:%(DEST_PORT)s/%(INDEX)s --type=data' | |
for index in INDICES: | |
print("Migrating %s Index..." % index) | |
os.system( | |
MAPPING_CMD.format({ | |
'SRC_HOST': SRC_HOST, | |
'SRC_PORT': SRC_PORT, | |
'DEST_HOST': DEST_HOST, | |
'DEST_PORT': DEST_PORT, | |
'INDEX': index | |
}) | |
) | |
print("%s Index Migrated" % index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment