Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup ElasticSearch with rsync
# 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
# true or false
DISABLE=$1
curl -XPUT 'localhost:9200/_settings' -d '{
"index" : {
"translog.disable_flush" : "'$DISABLE'"
}
}'
curl -XPOST 'localhost:9200/_flush'
curl -XGET 'localhost:9200/_settings?pretty=true'
@AndrewVos

This comment has been minimized.

Copy link

AndrewVos commented May 23, 2014

Does this actually work?

@ebuildy

This comment has been minimized.

Copy link

ebuildy commented Feb 23, 2015

Try it!

@lebowitz

This comment has been minimized.

Copy link

lebowitz commented Feb 24, 2015

Be careful when setting TO_FOLDER. The last line is dangerous.

@SenthilJothi

This comment has been minimized.

Copy link

SenthilJothi commented Dec 27, 2016

FROM=/your-es-installation

  1. FROM is my installation directory(/usr/share/elasticsearch) or wherever my index is stored>
  2. How to restore this backup?
  3. 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
You can’t perform that action at this time.