Skip to content

Instantly share code, notes, and snippets.

@drewr
Last active August 29, 2015 14:20
Show Gist options
  • Save drewr/8bb7bfbda1ed315f8c79 to your computer and use it in GitHub Desktop.
Save drewr/8bb7bfbda1ed315f8c79 to your computer and use it in GitHub Desktop.
Snap your marvel indices, without snapshot/restore
#!/bin/sh
pat='.marvel-*'
idxs=`curl -s localhost:9200/_cat/indices/${pat}\?h=index | sort`
single=`echo $idxs | tail -1`
id=`echo $pat | sed 's/[^a-zA-Z]*//g'`-`date -u +%s`
d=/tmp/$id
if [ -d $d ]; then
echo $d exists, delete and rerun $0
exit 1
fi
mkdir $d
echo saving mapping
curl -s localhost:9200/$single/_mapping >$d/mapping.json.txt
for i in $idxs; do
echo saving $i
stream2es es \
--source http://localhost:9200/${i} \
--no-indexing \
--tee-bulk $d
done
( cd $d/..; tar cf - $id ) | gzip >$id.tar.gz
echo created $id.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment