Recovering Influxdb

My openhab server crashed recently, fatal disk error and it would not boot. I’m using InfluxDB for persistance and although i was able to recover from backup, i lost about 5 days of data (weekly backup, crashed on day 6….)

However i could still access most of the filesystem bar a few files on the old SD card. So i wanted to recover any missing data. Here’s how i did it:

  • Copy the contents of /var/lib/influxdb from the old filesystem to $HOME/.influxdb on the new filesystem. This should include data, meta and wal folders.
  • Export the data i wanted, tailoring the database name and start date as needed:
    influx_inspect export -database openhab -start 2025-08-10T04:00:00+00:00
  • Note that influx_inspect export defaults to looking in $HOME/.influxdb hence my copying the files there. The result is a file called export in the same folder.
  • Now i can import the data into my new Openhab Influx database:
    influx -import -path=$HOME/.influxdb/export
  • Finally, i can remove all the backup files.
    rm -Rf $HOME/.influxdb/*

Surprisingly this worked!

Leave a Reply

Your email address will not be published. Required fields are marked *