Commit 506897fd authored by fwinkler's avatar fwinkler

Revised post processing script.

parent f51f90be
......@@ -65,7 +65,7 @@ function restore_influx()
echo "Restore influxdb..." 2>&1 | tee -a $DEBUG_PATH
# get all shards which are not restored yet
restore_shards=`mysql_command "select shard_id, start from Backup where success=1 and restored=0"`
#echo ${restore_shards} 2>&1 | tee -a $DEBUG_PATH
echo ${restore_shards} 2>&1 | tee -a $DEBUG_PATH
# convert string output into indexed array
IFS=', ' read -r -a shard_array <<< "${restore_shards}"
......@@ -82,6 +82,7 @@ function restore_influx()
do
shard_id=${shard_array[i]}
start_seconds=${shard_array[i+1]}
echo ${shard_id} 2>&1 | tee -a $DEBUG_PATH
source ${PIKA_ROOT}/post_processing/restore_influxdb.sh ${shard_id}_${start_seconds} 2>&1 | tee -a $DEBUG_PATH
error_text=`egrep -i "error|failed" $DEBUG_PATH | grep -v "Failed "`
......
......@@ -13,15 +13,19 @@ fi
SHARD=$1
#SSD would be much faster!!!
mkdir -p /data/temp_export
cd /data/temp_export
TEMP_EXPORT=/data/temp_export/$SHARD
TEMP_DIR=/data/temp_export
mkdir -p $TEMP_DIR
TEMP_EXPORT=$TEMP_DIR/$SHARD
# check if shard directory exists
if [ ! -d /data/influx_lt_backup/$SHARD ]; then
exit 1
fi
# remove old temporary database if exists
curl -POST "localhost:8086/query?u=$INFLUXDB_USER&p=$INFLUXDB_PASSWORD" --data-urlencode "q=drop database \"$SHARD\""
# restore shard into temporary database
influxd restore -portable -db "$INFLUXDB_DATABASE" -newdb "$SHARD" /data/influx_lt_backup/$SHARD/ &
sleep 1
......@@ -39,11 +43,12 @@ time influx_inspect export -datadir "/data/influxdb/data" -waldir "/data/influxd
# modfiy metadata of dumped file ###################################################
# get first 7 lines
head -n 7 $TEMP_EXPORT > header
HEADER=$TEMP_DIR/header
head -n 7 $TEMP_EXPORT > $HEADER
# modify metdadata and store in new file
sed -e "/CREATE DATABASE/c CREATE DATABASE prope_lt" -e "s/$SHARD/prope_lt/" -e '/CONTEXT-RETENTION-POLICY/d' header > ${TEMP_EXPORT}_mod
rm header
sed -e "/CREATE DATABASE/c CREATE DATABASE prope_lt" -e "s/$SHARD/prope_lt/" -e '/CONTEXT-RETENTION-POLICY/d' $HEADER > ${TEMP_EXPORT}_mod
rm $HEADER
# piping tail from original file to new file
time tail -n +8 $TEMP_EXPORT >> ${TEMP_EXPORT}_mod
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment