InfluxDB AddOn never updates normally

Every time InfluxDB needs an update on my HomeAssistantOS as an Addon it never updates without unticking “backup”.

Any tip or suggestion? I do really want a backup before updating

How big is your db?

Mine is 3GB and it takes about 30 minutes to backup using a core i7.

The magic question… I do not know how to see that

Install the comunity SSH & Terminal addon. Disable protection mode and run the add-on. Open the web terminal and run this command:

docker exec addon_a0d7b954_influxdb du -s /data/influxdb/data/homeassistant

image

Did you disable protection mode?

What did you call your influxdb database?

Yes sure.

home_assistant

image

Mine seems 20Gb… :frowning:

Then that is why you can’t update. The backup never finishes.

Are you recording everything?

I only include the sensors I’m interested in long term data for, for two years. I’m probably going to top out at about 5GB.

Partly. I have filtered put chatty sensors etc. I also have cleaned up recently. But I want to keep energy sensors “forever” (power usage etc.).

Its now about 3-4 years I think.

But how is it possible to not be able to backup?

It’s possible. You just have to wait 10 hours or so for the backup to finish.

Hi Tom, do you have any tip/guidance how to get the output of above command in a sensor?

I currently have this, which I believe I got from a long time ago other post from you but it is not accurate… (at all)

  - platform: influxdb
    host: a0d7b954-influxdb
    port: 8086
    username: !secret influxdb_user
    password: !secret influxdb_pass
    scan_interval: 3600
    queries:
      - name: InfluxDB DB size
        unit_of_measurement: MB
        value_template: '{{ (value | float / 1024 /1024) | round(1) }}'
        group_function: mean
        measurement: '"monitor"."shard"'
        database: _internal
        where: 'time > now() - 1m AND "database"=''home_assistant'''
        field: diskBytes

I have a whole topic discussing that.

In short yes.

You need an mqtt broker connected to home assistant and the SSH & web terminal addon with protection mode disabled. You then add this option to your SSH & web terminal addon configuration:

init_commands:
  - >-
    while [ 1 = 1 ]; do docker exec addon_a0d7b954_influxdb du -s
    /data/influxdb/data/homeassistant | mosquitto_pub -t
    home-assistant/sensor/dbsize -r -u <user> -P <password> -l && sleep
    300; done &

Replacing <user> and <password> with your mqtt broker connection credentials.

Then add this sensor to home assistant:

mqtt:
  sensor:
    - name: InfluxDB DB Size
      unit_of_measurement: 'MB'
      icon: hass:chart-line
      state_topic: "home-assistant/sensor/dbsize"
      value_template: "{{ (value.split('\t')[0]|int(0)/1000)|round(3) }}" 

@sender

concerning your huge database, did you ever think about “compressing” older data in your database just by keeping only one database entry per 15 minutes for example for the older ones?
I have wrote my way of shrinking the influxdb in a little tutorial, maybe this can help you to get rid of many gigabytes.

https://community.home-assistant.io/t/influxdb-setup-to-compress-data-older-than-6-months-2-years/412379

1 Like