Created
December 26, 2012 14:50
-
-
Save dadoonet/4380715 to your computer and use it in GitHub Desktop.
Backup Elasticsearch node
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
# Script to be placed in elasticsearch/bin | |
# Launch it from elasticsearch dir | |
# bin/backup indexname | |
# We suppose that data are under elasticsearch/data | |
# It will create a backup file under elasticsearch/backup | |
if [ -z "$1" ]; then | |
INDEX_NAME="dummy" | |
else | |
INDEX_NAME=$1 | |
fi | |
# Optimize index | |
curl -XPOST http://localhost:9200/$INDEX_NAME/_optimize | |
# Flush index | |
curl -XPOST http://localhost:9200/$INDEX_NAME/_flush | |
# Close index | |
curl -XPOST http://localhost:9200/$INDEX_NAME/_close | |
# Backup you data dir | |
mkdir backup | |
tar zcf backup/$INDEX_NAME.tar.gz data/elasticsearch/nodes/*/indices/$INDEX_NAME/ | |
# Then reopen index | |
curl -XPOST http://localhost:9200/$INDEX_NAME/_open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment