IoT - InfluxDB - Restore

Simple full restore IOT database

*** This applies for 1.4 version influxDB ***

see https://docs.influxdata.com/influxdb/v1.4/administration/backup_and_restore/

Script to restore from a mounted NAS directory

#!/bin/bash
set -x
#
# (c) DL2SBA 21.10.2018
#
# Restore a 1.4. InfluxDB
#
# Mount the network share
#
MOUNT_SOURCE="//192.168.2.242/backup"
MOUNT_TARGET="/mnt/backup"
MOUNT_USER=<user>
MOUNT_PASSWD=<pass>
umount -v /mnt/backup
mount -v -t cifs -o user=$MOUNT_USER,password=$MOUNT_PASSWD,rw,file_mode=0777,dir_mode=0777,uid=$MOUNT_USER,gid=users $MOUNT_SOURCE $MOUNT_TARGET
TARGETDIR=$MOUNT_TARGET/INFLUX/' date +%Y%m%d_%H%M%S'
#
# backup to restore
#
TARGET_VERSION="20181021_050001"
influxd restore -metadir /influx-db/influxdb/meta /mnt/backup/$TARGET_VERSION
influxd restore -database iot -datadir /influx-db/influxdb/data /mnt/backup/INFLUX/$TARGET_VERSION
#
# unmount network share
#
umount -v /mnt/backup
#
# cleanup permissions
chown -R influxdb:influxdb /influx-db/influxdb