InfluxDB hassio add-on: changing default database location

I’m running hassio on a solid state drive on my Linux server, and I wanted to install the InfluxDB add-on, but with the database residing on a separate hard drive on my system. I’d been having a tough time settling on a good way to do it, but I stumbled upon something yesterday that helped me, so I thought I’d pass along the steps I took.

1. Make sure the desired database location is accessible to hassio.

In my case, I had my external drive mounted to /usr/share/hassio/share/db. (I used an automount entry in /etc/fstab.) This allowed me to access my drive within hassio at the location /share/db. I was already using this to store my built-in Home Assistant database, which had grown to something of a monster and needed more room to roam.

To keep the InfluxDB files somewhat separate from the built-in database, I created a subdirectory called influxdb.

2. Install the InfluxDB add-on, setting a few InfluxDB environment variables when you do.

As @frenck notes in the README of his excellent add-on, the config allows you to set some environment variables for the InfluxDB configuration. This was the key.

Here’s what I used when I first fired up the add-on. The main section to note is the envvars section: make sure that all three directories you list under value start with /share/db/influxdb (or whatever you’ve called your directory in the previous step).

Also, I went ahead and created the three directories listed below (meta, data, and wal), but I don’t think that’s necessary. One of the resident gurus will hopefully clarify that…

I disabled auth just for configuration, since the add-on didn’t seem to want to start when I had it enabled. The setting for reporting is your call, and I wasn’t using ssl.

auth: false
reporting: false
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
envvars:
  - name: INFLUXDB_META_DIR
    value: /share/db/influxdb/meta
  - name: INFLUXDB_DATA_DIR
    value: /share/db/influxdb/data
  - name: INFLUXDB_WAL_DIR
    value: /share/db/influxdb/wal

3. Follow the InfluxDB add-on instructions for integrating with Home Assistant.

Once again, @frenck is here to save the day with his Home Assistant integration instructions in the README.

Note: if you disabled authentication in the second step above, go ahead and enable it before you restart. (Since you’ve created a user in the InfluxDB add-on and added the user’s credentials in configuration.yaml, you shouldn’t have any issues.)

4. Enjoy your data!

That’s it…I hope this helps someone and is at least reasonably accurate. Savvy users: please chime in if I’ve missed something or have something wrong, and I’ll update this so as not to mislead anyone in the future.

4 Likes

Great guide! I have a question. My InluxDB is running, if I change the DB location, what is going to happen to the old DB? it’ll be moved? deleted? stay unchanged?

Stop your influxdb add-on, move (or better copy to be sure ) your database to the new location, make the changes, restart influxdb add-on.

I’d agree with @francisp: probably best to copy the old database to the new location. Once that’s done and you’ve restarted, it should start updating your new database and leave the old one alone. Hope this helps!

I’m not sure how to do that. I’m using hassio/hassOS and the InfluxDB file is stored inside the InfluxDB add-on container. How can I access it??

On your host machine, look in /usr/share/hassio/addons/data/. There should be a directory for each addon (with the prefix a0d7b954_ before the addon name). Within the one for influxdb, go to the influxdb subdirectory, and you’ll find the data, meta, and wal subdirectories.

Thank’s, I’ll try that! First I’ll have to learn how to SSH to the HassOS as the SSH add-on have access only to the Home Assistant container.

Is there any solution for the authentication part? Because when i move my data and i disable authentication my created database is not showing in the InfluxDB admin page. And when i enable it InfluxDB will not start… Please help me in this case.

Username and password are both in the configuration file.

Unfortunately, I haven’t had much luck there. It hasn’t been at the top of my list of things to investigate, since I don’t use this data much right now. However, it’s something I keep meaning to look into. Hopefully someone will chime in with a solution…

I made an workaround for this “problem”.

Create a mountpoint to the location where the default meta,data and wal folder were created. In my case “/usr/share/hassio/addons/data/a0d7b954_influxdb/influxdb/”

So first move the three folder to a tmp folder.

mkdir /usr/share/hassio/addons/data/a0d7b954_influxdb_tmp

mv /usr/share/hassio/addons/data/a0d7b954_influxdb/influxdb/meta /usr/share/hassio/addons/data/a0d7b954_influxdb_tmp

mv /usr/share/hassio/addons/data/a0d7b954_influxdb/influxdb/wal /usr/share/hassio/addons/data/a0d7b954_influxdb_tmp

mv /usr/share/hassio/addons/data/a0d7b954_influxdb/influxdb/data /usr/share/hassio/addons/data/a0d7b954_influxdb_tmp

After this create the mountpoint to mv /usr/share/hassio/addons/data/a0d7b954_influxdb/influxdb and move the folders back. After this you can use auth and its all working nice :slight_smile:

1 Like

Very glad to hear you got it working…thanks for sharing your solution! I’ll have to give that a shot myself.

Hello,
I am also encountering the auth issue and created an issue on the addon page, but if someone here solved it I would love to hear the solution !
To sum up, to have everything working today I can either have db stored on specific location OR have auth enabled, but not both at the same time


Thanks for the help !

Very interesting topic! I also would like to change the location of the InfluxDB database, so that I can make a backup regularly. I’m running Hassio on an Intel NUC, and installed InfluxDB. It works OK, I can explore the data. When I access Hassio via WinSCP to search through the folders, I can not find the 3 described folders corresponding to InfluxDB. What am I doing wrong? Some hidden folders perhaps? Many thanks if someone can shine a light on this!

Same, same. I want to do exactly what you are trying to do. Anyone got it working??