Add-on: Home Assistant Google Drive Backup

I see the /backup in HA as /share/backup and see the snapshots
When I go into NPM via portainer and create a folder then in HA /share/backup I see same folder

I think I did a mistake in way how this work…

/share/ folder will be visible also in the NPM docker.

There is nothing wrong and strange… sorry for the confusion.

root@ha:/usr/share/hassio/tmp# docker inspect -f '{{.HostConfig.Binds}}' addon_cebe7a76_hassio_google_drive_backup
[/dev:/dev:ro 

/usr/share/hassio/addons/data/cebe7a76_hassio_google_drive_backup:/data:rw 
/usr/share/hassio/homeassistant:/config:ro 
/usr/share/hassio/ssl:/ssl:ro 
/usr/share/hassio/backup:/backup:rw]

root@ha:/usr/share/hassio/tmp# docker inspect -f '{{.HostConfig.Binds}}' addon_a0d7b954_nginxproxymanager
[/dev:/dev:ro 
/usr/share/hassio/addons/data/a0d7b954_nginxproxymanager:/data:rw 
/usr/share/hassio/ssl:/ssl:rw 
/usr/share/hassio/backup:/backup:rw]

root@ha:/usr/share/hassio/tmp# docker inspect -f '{{.HostConfig.Binds}}' homeassistant
[/dev:/dev:ro 
/run/dbus:/run/dbus:ro 
/run/udev:/run/udev:ro 
/usr/share/hassio/homeassistant:/config:rw 
/usr/share/hassio/ssl:/ssl:ro 
/usr/share/hassio/share:/share:rw 
/usr/share/hassio/media:/media:rw 
/etc/machine-id:/etc/machine-id:ro 
/usr/share/hassio/tmp/homeassistant_pulse:/etc/pulse/client.conf:ro 
/usr/share/hassio/audio/external:/run/audio:ro 
/usr/share/hassio/audio/asound:/etc/asound.conf:ro]

backup_directory_path is a configuration option I use for deveopment, its the file path to the backup folder. Setting it to anything will override it and can only make the addon stop working properly. You’re seeing it because a recent supervisor change fills all of the unspecified addon config options with default values like the empty string or 0. I have strong opinions on why this is bad but there isn’t much I can do about it except complain at the people who made it. To be honest its kind of a sore spot for me at this point.

I’m releasing an update that removes a lot of the more confusing options that you guys shouldn’t see, but in general I’d recommend using the settings UI inside the addon to make settings changes instead of the interface in the supervisor. If there is a configuration option that does something useful I’ve included it in that UI. I don’t hide functionality through obscurity.

Hi. Im having some trouble with the addon.
I keep getting a Connection Timeout.
Only thing I have changed is that I started usin Nabu Casa. Can it be the problem?
Tried googling, but couldn’t find a answer/solution

I tried to search in the thread but it’s a very long thread and I didn’t see it so apologies if this has been addressed but… I have a hassio install on a pi on the latest version and when I install the add-on and then try to start it I get the following error. I tried removing it and installing it again and the same issue. I haven’t even gotten to a point where I create a configuration.

21-04-01 22:22:09 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/aiohttp.py", line 123, in sentry_app_handle
    reraise(*_capture_exception(hub))
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/_compat.py", line 54, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/aiohttp.py", line 113, in sentry_app_handle
    response = await old_handle(self, request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/supervisor/supervisor/api/security.py", line 135, in system_validation
    return await handler(request)
  File "/usr/src/supervisor/supervisor/api/security.py", line 197, in token_validation
    return await handler(request)
  File "/usr/src/supervisor/supervisor/api/utils.py", line 65, in wrap_api
    answer = await method(api, *args, **kwargs)
  File "/usr/src/supervisor/supervisor/addons/addon.py", line 627, in start
    await self.instance.run()
  File "/usr/src/supervisor/supervisor/utils/__init__.py", line 32, in wrap_api
    return await method(api, *args, **kwargs)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/supervisor/supervisor/docker/addon.py", line 467, in _run
    "Starting Docker add-on %s with version %s", self.image, self.version
  File "/usr/src/supervisor/supervisor/docker/addon.py", line 58, in image
    return self.addon.image
  File "/usr/src/supervisor/supervisor/addons/addon.py", line 394, in image
    return self.persist.get(ATTR_IMAGE)
  File "/usr/src/supervisor/supervisor/addons/addon.py", line 159, in persist
    return self.sys_addons.data.user[self.slug]
KeyError: 'cebe7a76_hassio_google_drive_backup'
21-04-01 22:22:09 INFO (SyncWorker_0) 

@calisro what you’re seeing is definitely a supervisor bug. There are many problems the supervisor can run into and they’re all very mysterious. There are a lot of things it caches and … things can just go wrong all over the place in ways that look random if the docker environment it creates isn’t just perfect. What I’d try doing first is:

  • Make sure the supervisor/HA is up to date
  • Uninstall the addon
  • Remove the addon’s repository
  • Restart the host machine
  • Add the repository back and reinstall the addon
  • Stop here and check the supervisor logs there might be a more helpful error message there from then the supervisor was starting up or during the addon’s installation.
  • Start the addon

This solves like, 90% of the problems people run into with the supervisor.

1 Like

Amazing

quick and painless install - works perfectly.
thank you for your efforts.

Amazing Add-on!!
Could someone help me with a automation that notifies my phone everytime there is made a new backup?
I only managed to make one that tells me if there is an error with the backup.

First, I’d advise against having a notification when a snapshot is created because notifying when things are working correctly contributes to alarm fatigue.

But if you still insist:

  • First create a template sensor in configuration.yaml that stores the name of the latest backed up snapshot:
    sensor:
    - platform: template
      sensors:
        latest_backup:
          value_template: >-
            {% set found=namespace(snapshot=None,time=0) %}
            {% for snapshot in state_attr('sensor.snapshot_backup', 'snapshots') %}
              {% if as_timestamp(snapshot.date) > found.time and snapshot.state == "Backed Up" %}
                {% set found.time = as_timestamp(snapshot.date) %}
                {% set found.snapshot = snapshot %}
              {% endif %}
            {% endfor %}
            {{ found.snapshot.name }} ({{ found.snapshot.size}})
    
  • Then make an automation that sends you a notification when the most recently backed up name changes, ignoring when the state changes from an unknown value (when HA starts up initially).
    - alias: Notify for a new backup
      trigger:
      - platform: state
        entity_id: sensor.latest_backup
      condition:
      - condition: template
        value_template: '{{trigger.from_state.state != None and trigger.from_state.state
        != '''' and trigger.from_state.state != ''unavailable''}}'
      action:
      - service: notify.your_notification_target
        data:
          title: New Snapshot
          message: Created and backed up {{states('sensor.latest_backup')}}
    

Note that this will also trigger an erroneous notification if you delete the latest snapshot and it would also be possible to create this using only an automation. The logic for solving these problems would be pretty complicated.

2 Likes

Hello.
With a new installation (Home Assistant OS 5.13, supervisor-2021.04.0, core-2021.4.4), i can’t install this add-on.
The msg : 21-04-14 15:06:43 ERROR (SyncWorker_3) [supervisor.docker.interface] Can’t install sabeechen/hassio-google-drive-backup-aarch64:0.103.1 → 500 Server Error for http+docker://localhost/v1.40/images/sabeechen/hassio-google-drive-backup-aarch64:0.103.1/json: Internal Server Error (“layer does not exist”).
This add-on work fine with my previous installation.
Help ! Please !

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