Files
tpotce/installer/bin/restore_elk.sh
2017-03-17 23:47:04 +00:00

46 lines
1.0 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#/bin/bash
myDUMP=$1
myES="http://127.0.0.1:64298/"
myCOL1=""
myCOL0=""
# Check if parameter is given and file exists
if [ "$myDUMP" = "" ];
then
echo $myCOL1"### Please proive a backup file name."$myCOL0
echo $myCOL1"### restore-elk.sh <es_dump.tgz>"$myCOL0
echo
exit
fi
if ! [ -a $myDUMP ];
then
echo $myCOL1"### File not found."$myCOL0
exit
fi
# Unpack tar archive
echo $myCOL1"### Now unpacking tar archive: "$myDUMP $myCOL0
mkdir tmp
tar xvfz $myDUMP -C tmp
cd tmp
# Build indices list
myINDICES=$(ls | cut -c 1-19)
echo $myCOL1"### The following indices will be restored: "$myCOL0
echo $myINDICES
echo
for i in $myINDICES;
do
# Delete index if it already exists
curl -s -XDELETE $myES$i > /dev/null
echo $myCOL1"### Now uncompressing: "$i".gz" $myCOL0
gunzip $i.gz
# Restore index to ES
echo $myCOL1"### Now restoring: "$i $myCOL0
elasticdump --input=$i --output=$myES$i --limit 7500
rm $i
done;
cd ..
rm -rf tmp
echo $myCOL1"### Done."$myCOL0