Add-on: Home Assistant Google Drive Backup

I’m also seeing the 500 error. I’m happy to provide the URL in a private message. In the meantime, here’s a URL with the sensitive bits removed:

https://philosophyofpen.com/login/backup.py?redirectbacktoken=https%3A%2F%2F[my.domain.com]%3A%2Fapi%2Fhassio_ingress%2F[some sort of token]%2Ftoken

A few extra details:

  • I’ve never installed this addon so I don’t have a snapshot to go back to (like @cjackson234 had)
  • I’m using nginx proxy manager addon + letsencrypt for ssl
  • I tried the google api process, but since I’m not a gsuite user, I would have been forced to select “external” for the app type, exposing it to any user with a google account.

[UPDATE] It’s working now! I didn’t change anything on my end. Perhaps just a server hiccup?

I have a feeling there might be a conflict in the numbers of snapshots local/Drive and the rotation mechanisms. The issue has potentially emerged because of my drive getting a little full.

If I set up generational backups as 7 days and 2 weeks, that will mean 9 backups. However, I (up to now) have only specified 6 backups local and 4 on Drive.

I am not sure how the add-on reconciles the numbers.

What I have ended up with is simply the last 6 days locally and older backups on Drive.

I wonder if there should be a backstop position that, if there is insufficient space on Drive, then the number stored is reduced (with a warning) but it continues to maintain the latest backups on Drive.

Should there be a setting that allows different numbers of generational backups on Drive (so x Weekly + x daily).

at the risk of being incredibly silly, but having all these great snapshots on Gdrive, how can I flash a new sd card from these? reason I ask is I have 3 HA instances, all backed up nicely. I hate having a card die on me and needing to spend several hours rebuilding all, while I could simply have a spare sd card with a complete backup ready to pop in (flashed from the Gdrive)

How can I do that? thanks for having a look…

1 Like

I found the fastest way to recover was:

  1. Flash a new HA image on a SD card.
  2. Start HA and install the Google Drive Backup add-on.
  3. Browse the backed up images, download and restore.
2 Likes

@Mariusthvdb
I’m not aware of a way to merge a snapshot into an SD card without actually starting the instance. It would need to be something supported in the supervisor, since it would depend so heavily on all the places the supervisor stores information. It would be really handy though.

Indeed! Of course I can see the option Roelof describes above, bit I see that still as a second best option, and hardly an immediate swap backup recovery. Imagine your production system crashes, and you have to restart all the way by installing the main image first, etc etc.

compare that to having a full snapshot flash option available…It would be 2 minutes up and running, no hassle and a full system restore as we were…

Isnt there some linux trickery to be done on the snapshots? I imagine the internal commands HA follows do the same when restoring from a snapshot? Or isn’t that a flash, and merely a docker install (or whatever it is called these days)…

Maybe we should always have a brand-new image burn available, eg on the new releases x.2 (never use the .0 !) with your add-on installed, ready to go.

Would we need only that or also the ssh, samba and duckdns (if used) to get going?

Not everyone runs HA on a RPi and SD card. I use this fantastic add-on for my NUC based HA system running on top of Ubuntu. Having the snapshot feature you talk about would only be possible for a certain HA user group

of course, I understand that. I wasn’t really talking about a new feature for the add-on. Merely seeking a way to use the snapshots in the process of flashing a new Sd card. Id fully appreciate it if that would be outside any HA interface. Then again, it would be cool if it were in it :wink: Why not have the snapshot restore use a file browser… though I think I read it that is not allowed.

I think it’s a great idea. For me, it’s not as simple as sticking in a newly formatted SD card. I have to get into a tight utility closet, disconnect the RPi from the hardwired sensor connectors, remove the 3A power supply, drag it to a desk, dig out an old USB keyboard and mouse, find and connect an HDMI cable that will reach a TV, or drag in an old monitor.

It would be SO much easier if I could stick an SD card in my laptop and restore the whole system to that.

And since the main web site for HA strongly recommends a RPi installation for new users, I don’t think it’s too unreasonable to support that environment first.

I have an open feature request that, from the registration screen on a fresh install, there is the option to upload a backup.

@sabeechen @CaptTom

voted my +1 :wink:

1 Like

Just added my vote :slight_smile:

1 Like

I had this up and running via an automation, but it seems to have stopped working on the 7th June. My config hasn’t changed - has there been an update?

My logs now show:

{“errorMessage”: “Redirected but the response is missing a Location: header.”}

When I try to call the service via REST. Any ideas?

EDIT: Sorry - I’m an idiot! I was using a different plugin - have switched to this one and it is much better! Thanks!

apologies if this is the wring place to post this…
I have an automation set to notify me via the mobile app (Android)
the last month or so it hasnt been triggering.
the action part works OK, as i can fire it manually and get the mobile notification OK
Am i missing something with the trigger?

- alias: Snapshot made notification
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.snapshot_backup
  condition:
    - condition: template
      value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
  action:
    - service: notify.mobile_app_oneplus7pro
      data_template:
        title: Snapshot Update
        message: |
          {{ states.sensor.snapshot_backup.attributes.snapshots[1].name }}
          Snapshots on Drive: {{ states.sensor.snapshot_backup.attributes.snapshots_in_google_drive }}
          Snapshots stored locally: {{ states.sensor.snapshot_backup.attributes.snapshots_in_hassio }}

The state of sensor.snapshot_backup will only ever be

  • backed_up (when things are working),
  • error (when there is a problem)
  • waiting (when it first starts up)

so I don’t think this trigger will work as you expect. If you want to get a notification when a new upload happens, I think you’ll need to trigger based on changes to sensor.snapshot_backup.attributes.last_snapshot, which is the date (in text, ISO format) of the most recent snapshot.

That is how I do it :

sensor:

  - platform: template
    sensors:
      last_backup:
        friendly_name: "Last Backup"
        value_template: "{{state_attr('sensor.snapshot_backup', 'last_snapshot')}}"

automation :

- id: '1593338157847'
  alias: Last backup
  description: ''
  trigger:
  - entity_id: sensor.last_backup
    platform: state
  condition:
    - condition: numeric_state
      entity_id: sensor.time_online
      above: 3  
  action:
  - data:
      message: Backed up
    service: notify.notifier_doorbell

Notice the use of the condition sensor.time_online ( the uptime integration) to not get a notification when HA restarts.

Thanks both, this makes more sense.
ive updated my config, will wait for the next update to run

This morning I discovered that my system was trying to create a full backup (~85Gb due to CCTV footage that would normally be excluded) rather than the usual partial one. It seems that the last update of this add-on erased my backup settings and set them to default. Has anyone else had the same?

So the automation ran, but it gave me 2 notifications from the android app?

- alias: Snapshot made notification
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.last_backup
  condition:
    - condition: numeric_state
      entity_id: sensor.ha_time_online
      above: 3
  action:
    - service: persistent_notification.create
      data_template:
        title: Snapshot made
        message: >-
          {{ states.sensor.snapshot_backup.attributes.snapshots[3].name }}
          Snapshots on Drive: {{ states.sensor.snapshot_backup.attributes.snapshots_in_google_drive }}
          Snapshots stored locally: {{ states.sensor.snapshot_backup.attributes.snapshots_in_hassio }}
    - service: notify.mobile_app_oneplus7pro
      data_template:
        title: Snapshot Update
        message: |
          {{ states.sensor.snapshot_backup.attributes.snapshots[3].name }}
          Snapshots on Drive: {{ states.sensor.snapshot_backup.attributes.snapshots_in_google_drive }}
          Snapshots stored locally: {{ states.sensor.snapshot_backup.attributes.snapshots_in_hassio }}- alias: Snapshot made notification
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.last_backup
  condition:
    - condition: numeric_state
      entity_id: sensor.ha_time_online
      above: 3
  action:
    - service: persistent_notification.create
      data_template:
        title: Snapshot made
        message: >-
          {{ states.sensor.snapshot_backup.attributes.snapshots[3].name }}
          Snapshots on Drive: {{ states.sensor.snapshot_backup.attributes.snapshots_in_google_drive }}
          Snapshots stored locally: {{ states.sensor.snapshot_backup.attributes.snapshots_in_hassio }}
    - service: notify.mobile_app_oneplus7pro
      data_template:
        title: Snapshot Update
        message: |
          {{ states.sensor.snapshot_backup.attributes.snapshots[3].name }}
          Snapshots on Drive: {{ states.sensor.snapshot_backup.attributes.snapshots_in_google_drive }}
          Snapshots stored locally: {{ states.sensor.snapshot_backup.attributes.snapshots_in_hassio }}

Yes. It seems the sensor changes twice within about 2 minutes. I don’t know if it is a bug or intentional.