Add-on: Home Assistant Google Drive Backup

Unfortunately, this is one of a number of issues I’ve seen come up with the supervisor that I’ve never been able to find a root cause for. I’m not sure if its a problem in the addon or the supervisor, but I lean toward the supervisor. Try following the steps I recommended here:

Hi,

I’ve been trying to figure out what is causing my disk to keep filling up and it seems that every time a backup is taken (spike in the picture below) it ends up taking about 100 mb more than it used to.
The spikes happen daily at around 6:30 which is how I have set it up.

disk space

I keep only a few snapshots in HA before they are deleted.
google backup

Can someone help me so that my SSD (250 Gb) doesn’t end up full eventually?
(I have deleted the db files and moved to MariaDB and it didn’t affect much.)

It’s been awhile and I’m not at home but I seem to remember that you can set it up to create a set number of backups and the oldest one would then be deleted therefore it should never grow bigger than the size of the number of backups?

Yeah, I only have 4 snapshots in HA as is shown in the second screenshot. So that shouldn’t be the problem.

Thank you. Unfortunely, no success.
I wil try again and again. And if it doesn’t work, i will make a new install from scratch.

Hi
I’m having an issue preforming daily Google backups where is doesn’t seem to delete the oldest backup and therefore gives the message that the ‘Google Drive is out of space’. So I manually delete the oldest and the backup transfer to Google drive start automatically. It’s the same setup Ive been using for months. Now this issue happens daily. Any ideas?

5310

FYI: This has been my favorite HA add-on. Great work.

@Bagoonga The supervisor is what actually creates the snapshots and when it does so it creates a lot of temporary files that get cleaned up eventually. The addon itself uses very little disk space and is unlikely to be the cause. I suspect that your system would reclaim the missing space eventually but if you’d like to dig into it further you could try:

  • Restarting the host machine and seeing it the used space comes back. That would indicate its likely just temp files.
  • Installing the portainer addon and seeing which docker container is using the extra disk.

@5310 The addon doesn’t delete a snapshot until it can do so without going below the snapshot limit which is by design. Google Drive needs to have enough space for max_snapshots_in_google_drive + 1

Alright, big release at v0.104.1. I’ve been sitting on this one for a while and its probably the most changes I’ve ever released at once. The Highlights are:

  • Complete UI redesign, thanks almost entirely to contributions from @ericmatte. Things are mostly in the same place and should feel familiar, but everything is just better.
  • Lots of quality-of-life improvements due to the UI revamp.
  • Added config options for making the addon ignore either the new “upgrade snapshots” that the supervisor creates or just to ignore any snapshot it doesn’t create check the settings in the web-ui to enable it.
  • Removed a lot of the unused config options made more visible by the supervisor’s addon config UI. I still recommend using the addons web-ui to change settings.
  • Added a config option to delete snapshots from HA immediately after uploading to Google Drive. You can use this to minimize disk usage in HA.
  • Added some better handling of retrying failed uploads to Drive. People on flaky connections should see better performance uploading large snapshots.
  • Added support for the “Content Manager” role if you’re storing snapshots on a Shared Drive where you aren’t the owner.

See the changelog for a list of all the changes in this release.

To update the addon, just wait if you have auto update or go to:
Supervisor > Add-on Store > Click the ... in the top right > Refresh
and you should see the new version. Hope you guys like it!

This project has a web-based component (habackup.io) that costs real money to continuously run, but is also free for you to use. Join those who keep the lights on by donating at

6 Likes

Why is this add-on not part of the official Home Assistant Add-ons? Sounds to me it’s a vital one.

4 Likes

Hi
I’ve been having have an issues where my google drive is full after 2 backups. It seems that it deletes the flagged Google backup to delete, after the new one is copied. Can you please add a flag to give a option to delete BEFORE or AFTER when synching to Google Drive.

Thanks. This is a great ADDON, one of the BEST.
5310

not sure off this has been touched before, but I needed to debug the http component, and see a

2021-05-06 20:44:49 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated 172.30.32.2 for /api/states/binary_sensor.snapshots_stale using bearer token
2021-05-06 20:44:49 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/states/binary_sensor.snapshots_stale to 172.30.32.2 (auth: True)

being performed every 10 seconds. That seems a bit over active for a check on a daily backup in my case…
can we somehow lower the update frequency on this?

You could instead just turn off the sensors that get published to Home Assistant in the addon settings. they’re listed as Enable Snapshot Stale Sensor and Enable Snapshot State Sensor in the addon’s setting dialog.

This feature has a long and sordid history, but it pings this frequently because the request acts like a heartbeat to let the addon know when Home Assistant is running, which is important for other reasons. Unfortunately I’m not aware of a way to do such a check without spamming a different and much more visible log.

thanks for getting back to me so quickly.
of course I don’t really understand why this would be necessary in the internal workings of your great add-on, but seems a check on another binary in HA would suffice for that. Since these change on state in HA it wouldn’t need to poll, but could use the pushing state change of that sensor.

And then rely on the default sync interval of once per hour…

but, repeat, I don’t understand the inner workings so sorry if this sound to silly to be useful. But because you say we can easily disable these sensors and still have the add-on work properly, it seems not to depend on that at all?

seems a check on another binary in HA would suffice for that

The addon runs in a isolated and sandboxed environment (a docker container) and can only communicate with Home Assistant, the supervisor, etc over the network through their APIs. This is the way the devs for HA designed things to work.

because you say we can easily disable these sensors and still have the add-on work properly, it seems not to depend on that at all?

The hearbeat is needed to support the publishing of the sensors, so if the sensors aren’t getting published no hearbeat is needed. This is because when Home Assistant shuts down it deletes all sensors that aren’t part of a built in integration (ie part of its code base). When Home Assistant starts up again (ie if you restart it, upgrade, etc) the addon needs to notice and make sure it sensors are published as soon as possible. If the addon doesn’t do this or polls infrequently, users get confused because the sensors don’t show up for a while after a restart.

Everything is a tradeoff, and while I’m open to suggestions this is the best one I could come up with. Debug logs are expected to be a little spammy, and this is the least obtrusive place I’m aware of where the addon can check. Plus you can turn it off if you want to.

1 Like

thanks, appreciate the educational post a lot.

A yes, always impatient :wink: though I would think once per minute would still suffice in that case, even after a restart. In a heavy system, (and especially when run on a PI…) each cut we can make can be relevant. Would you accept a FR for that in that case?

final question then: if I disable the sensors, can I still select the persistent notification in the stale-ness?
in the add-on ui this seems totally possible:

another question, maybe even a FR…

seems we can not customize the snapshot sensors your add-on creates. Especially for the state sensor, this is a pity, because it show the default eye icon and slugged state, which is not so very nice to look at in the frontend.


Ive tried:

    sensor.snapshot_backup:
      entity_picture: /local/images/snapshot.png #which is the colored logo of your google-ha merge

but that wont work. ( I wont even bother you with my efforts to use custom-ui and set an icon color…)

I have the same experience with sensors created in a python script, and always customize the settings in the scripts because of that.
to cut it short, would you please consider adding an icon, or allowing us to override that with a nice png of your add-on logo, via the config settings of the add-on?
thanks for considering.

How do I get a message in telegram after performing a backup?
Как получить сообщение в телеграм по факту выполнения резервного копирования?

image
image

For this to work, you need to create sensors
Чтобы это работало, нужно создать сенсоры

sensor:
 - platform: template
   sensors:
    last_google_backup_main:
       friendly_name: 'Last successful backup - '
       value_template: '{{ (as_timestamp(states.sensor.snapshot_backup.attributes.last_snapshot)) | timestamp_custom("%d.%m.%Y %H:%M") }}'
       icon_template: mdi:calendar-check-outline

 - platform: template
   sensors:
    snapshots_in_google_drive_main:
       friendly_name: 'Snapshots on Googe Drive - '
       value_template: '{{ states.sensor.snapshot_backup.attributes["snapshots_in_google_drive"] }}'
       icon_template: mdi:folder-google-drive
       
 - platform: template
   sensors:
    snapshots_in_hassio_main:
       friendly_name: 'Snapshots in Nassio - '
       value_template: '{{ states.sensor.snapshot_backup.attributes["snapshots_in_hassio"] }}'
       icon_template: mdi:home-assistant

Next, we will create automation, where the last successful backup sensor will act as a trigger
Далее создадим автоматизацию, где в качестве триггера у нас будет выступать сенсор последний удачный бэкап

alias: 'System: Backup. Notification'
description: 'After creating a backup, a message about the successful backup will be sent to Telegram'
trigger:
  - platform: state
    entity_id: sensor.last_google_backup_main
condition: []
action:
  - service: notify.user
    data:
      message: |
        Hassio backup completed
        Number of backups: {{ states.sensor.snapshots_in_hassio_main.state }}
        Date of creation: {{ states.sensor.last_google_backup_main.state }}
      title: '*Home Assistant*'
mode: single

The full version of automation, which starts the backup at the specified time, turns on the auxiliary backup switch, then the sensor of the last successful backup is triggered and turns off the auxiliary backup switch. I used the backup auxiliary switch so that after restarting the Home Assistant, a false message about creating a backup would not arrive.
Полная версия автоматизации, которая запускает резервное копирование в указанное время, включает вспомогательный переключатель бэкапа, потом срабатывает сенсор последнего удачного бэкапа и выключает вспомогательный переключатель бэкапа. Вспомогательный переключатель бэкапа я задействовал для того, чтобы после перезагрузки Home Assistant не прилетало ложное сообщение о создании бэкапа.

  alias: 'System: Backup. Creating a backup.'
  description: This automation starts the backup service
  trigger:
  - platform: time
    at: 02:00 # Automation start-up time
  condition:
  - condition: state
    entity_id: input_boolean.backup_hass # The backup hass auxiliary switch is off
    state: 'off'
  action:
  - service: hassio.snapshot_full # Starting a backup
    data:
      name: Automatic Backup {{ states('sensor.time_date')}}
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.backup_hass # Switch the backup hass auxiliary switch to the on position
  mode: single

  alias: 'System: Backup. Notification'
  description: After creating a backup, a message will be sent to Telegram
  message about successful backup execution
  trigger:
  - platform: state
    entity_id: sensor.last_google_backup_main # Sensor of the last successful backup
  condition:
  - condition: state
    entity_id: input_boolean.backup_hass # The backup hass auxiliary switch is on
    state: 'on'
  action:
  - service: notify.user
    data:
      message: |
        Hassio backup completed
        Number of backups: {{ states.sensor.snapshots_in_hassio_main.state }}
        Date of creation: {{ states.sensor.last_google_backup_main.state }}
      title: '*NAS Home Assistant*'
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.backup_hass # Switch the backup hass auxiliary switch to the on position
  mode: single
1 Like

He is posting English as well as his native language so no need to say that to him.

haha… i thought it was sort of subject and then text part… haha
But same as Korea… long lines for less words in english haha