daily compression of InfluxDB

InfluxDB is an open source time series database built by InfluxData and used in e.g. Openhab for data persistance.
For small computers like raspi’s it is a best practice to compress the database regurlarly.

Why not using cron ?

Well, it works.. the only (security)-drawback is to grant /bin/bash to the influx-user:

cat /etc/cron.daily/00influx:


cat /home/pi/1_influxrepair.sh:

service influxdb stop
echo "before su"
su influxdb -c /home/pi/1_subscript.sh
echo "after su"
service influxdb start

cat /home/pi/1_subscript.sh:

echo "now in sub shell"
cd /var/lib/influxdb
influx_inspect buildtsi -compact-series-file -datadir ./data -waldir ./wal
echo "exiting sub shell"

cat /etc/passwd|grep infl:

modify influxdb:/bin/bash


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.