Skip to content

Instantly share code, notes, and snippets.

@calebphillips
Forked from drewr/save-indices.sh
Last active August 29, 2015 14:20
Show Gist options
  • Save calebphillips/6f2991894f5011ab38f3 to your computer and use it in GitHub Desktop.
Save calebphillips/6f2991894f5011ab38f3 to your computer and use it in GitHub Desktop.
#!/bin/sh
pat='.marvel-2015.04.29'
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