Created
July 10, 2011 20:05
-
-
Save karussell/1074906 to your computer and use it in GitHub Desktop.
Backup ElasticSearch with rsync
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
# TO_FOLDER=/something | |
# FROM=/your-es-installation | |
DATE=`date +%Y-%m-%d_%H-%M` | |
TO=$TO_FOLDER/$DATE/ | |
echo "rsync from $FROM to $TO" | |
# the first times rsync can take a bit long - do not disable flusing | |
rsync -a $FROM $TO | |
# now disable flushing and do one manual flushing | |
$SCRIPTS/es-flush-disable.sh true | |
$SCRIPTS/es-flush.sh | |
# ... and sync again | |
rsync -a $FROM $TO | |
$SCRIPTS/es-flush-disable.sh false | |
# now remove too old backups | |
rm -rf `find $TO_FOLDER -maxdepth 1 -mtime +7` &> /dev/null |
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
# true or false | |
DISABLE=$1 | |
curl -XPUT 'localhost:9200/_settings' -d '{ | |
"index" : { | |
"translog.disable_flush" : "'$DISABLE'" | |
} | |
}' |
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
curl -XPOST 'localhost:9200/_flush' |
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
curl -XGET 'localhost:9200/_settings?pretty=true' |
Try it!
Be careful when setting TO_FOLDER. The last line is dangerous.
FROM=/your-es-installation
- FROM is my installation directory(/usr/share/elasticsearch) or wherever my index is stored>
- How to restore this backup?
- What things are been backed up by this script?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this actually work?