It makes sense to backup the InfluxDB periodically so we don’t loose all our data.
We can do this in the terminal by:
influxd backup -portable /home/pi/influx_backup/
Make it run every night at 2am by opening crontab and adding the below code:
crontab -e
0 2 * * * influxd backup -portable /home/pi/influx_backup/
Now it would make sense for the above location to be a USB drive etc. as if our main drive fails we would loose the backup along with the original data. We can do this by updating the crontab -e to:
0 2 * * * influxd backup -portable /media/YOUR_USB_DRIVE_NAME
I had to instal the below package to allow the RaspberryPi write to the USB drive:
sudo apt-get install ntfs-3g
Another improvement would be to put all this in a script and push to another machine maybe over FTP but this is as far as I got right now and works well.
We can also see how much data is on the USB Drive by the below, maybe we will log this to Influx in future to keep an eye on backup sizes.
du -sh /media/YOUR_USB_DRIVE_NAME
That’s it!