IoT - InfluxDB - Backup

Simple full backup IOT database

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

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

Script for backup to mounted NAS directory

#!/bin/bash
set -x
#
# (c) DL2SBA 25.08.2018
#
# Unmount the shar
#
umount -v /mnt/backup
#
# Mount the network share
#
MOUNT_SOURCE="//<ipadr>/backup"
MOUNT_TARGET="/mnt/backup"
MOUNT_USER="<user>"
MOUNT_PASSWD="<pass>"
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

#
# backup the influx database IOT
#
TARGETDIR=$MOUNT_TARGET/INFLUX/` date +%Y%m%d_%H%M%S`
influxd backup $TARGETDIR
influxd backup -database "iot" $TARGETDIR

#
# Unmount the network share
#
umount -v /mnt/backup

Daily backup

Add this line to the crontab of root

0 5 * * * /home/dietmar/bin/backupInflux.sh  | /usr/bin/logger -t influxbackup