Add-on: Home Assistant Google Drive Backup

I’m trying to follow the instructions to create new credentials as I too got the email from Google. It seems the instructions don’t match what I see in the Google console so trying to follow them isn’t going too well for me…

  • In the menu on the upper left, click Enabled APIs & Services then OAuth Consent Screen.

This just shows me the existing OAuth I have setup for Assistant Relay with no option to create a new one…

You probably have mroe than one “project” in Google cloud, most likely one for the addon and one for the HA Relay. Google only lets you make one consent screen per project (I think…). You can switch projects using the drop down list next to “Google Cloud Platform” at the top of the page.

If you’re using the same Google Cloud project for both, which is also possible, you can click “Edit App” at the top of the Consent screen page to make changes to it. You should just need to make sure you’ve set the options listed in the guide.

Hello,
Awesome utility!
Installed and started to use this add-on 5 days ago. I have configured to generate 1 backup daily at 3 AM. Everything mostly working ok, except that looking into logs I see that sometimes, at expect time of completion there is message “WARNING A backup was already in progress”, and no file is copied to Google Drive. The the add-on retries 3 hours later and finally has been able to correctly complete the process. I have see up to two retries required before successful completion.
My experience so far:
Day 1 - Backup Completed normally
Day 2 - Backup Completed normally
Day 3 - Backup completed 3 hours later then scheduled, one reattempt required.
Day 4 - Backup completed 6 hours later then scheduled, two reattempts required.

What can be the reason for failed attempts?

Thank you

The most likely possibility is that Home Assistant (the supervisor specifically) is rejecting the request to create a backup for some reason. This might be because a backup really is already in progress, or because the supervisor is in one of its modes where it doesn’t let backups (or other changes) get made. The addon is unable to tell the difference Home Assistant doesn’t expose that information to it. On the first failure you should be able to find something in the sueprvisor’s logs that give more detail about why it refused to make a backup.

In my case, successful backups take about half hout to generate. On the failed attempts, i see the following sequence

05-29 03:01:34 INFO Requesting a new backup
05-29 03:34:20 WARNING A backup was already in progress

The warning message is reported at the time when backup would be completed, not when starting.
Also I can see from CPU and File system usage stats that the system is “working” in generating the backup, but finally, after half hour, the CPU returns to normal, disk space is freed, and no backup file can be found.
I have checked system logs, and could not find any registries related to this issue.

On successfull backup, the Add on logs are as follows:

5-29 06:01:36 INFO Requesting a new backup
05-29 06:34:21 INFO Backup directory changed
05-29 06:34:24 INFO Syncing Backups
05-29 06:35:37 INFO Backup finished
05-29 06:35:37 INFO Syncing Backups
05-29 06:35:42 INFO Uploading ‘Full Backup 2022-05-29 06:01:34’ to Google Drive
05-29 06:36:36 INFO Deleting ‘Full Backup 2022-05-29 06:01:34’ from Home Assistant
05-29 06:36:37 INFO Syncing Backups
05-29 06:36:42 INFO Backup directory changed
05-29 06:36:42 INFO Syncing Backups

Screenshot of CPU and Disk usage of failed attempt and then successful attempt three hours later:

I have been able to finally find out the reason for failed backups. When it fails, following error is registered in supervisor log:

22-06-05 09:34:03 ERROR (MainThread) [supervisor.homeassistant.module] Can’t backup Home Assistant Core config folder: [Errno 2] No such file or directory: ‘/data/homeassistant/zigbee.db-journal’

This error causes Home Assistant Backup to be interrupted and no backup file is generated.

I found little information about this problem. Most relevant is: https://community.home-assistant.io/t/failure-to-create-backup-filenotfounderror-on-zigbee-db-journal/397822

but no solution so far

Opened ticket in Gitlab: https://github.com/home-assistant/core/issues/73067

You might be able to work around this by instructing instructing this add-on to stop the offending add-on while its taking a backup (Settings > Stop Addons).
I added that to this add-on before Home Assistant allowed add-ons to have special behavior during backups and it still works today.
Alternatively you could exclude that addon from backups (eg use a partial backup) until its fixed.

This addon is in a difficult situation when an backups fails, because Home Assistant doesn’t expose a way to determine if a backup failed and the only way to see if a back up is in progress is to ask for a new backup and get an error reponse back. When a backup fails, the addon waits for it to time out (6 hours iirc) before it will try again.

Thanks for response. The failure is related to the zigbee service, which is provided via ZHA integration, and not an add-on, thus I do not think it can be stopped or excluded.
I can see following the Github ticket I opened that a team has started to discuss possibilities to address the issue.

BTW, you mention a timeout of 6 hours for automatic retry of backup after a failure. In my case I am observing 3 hours. Can this be configured somewhere?

i don’t know if you made something about permanent retention so,
i made a rest command in order to call it as a service but i cant retrive the last backup’s slug number in the payload section… it can be retrived from sensor.backup_state attribute maybe.
can anyone help me??

rest_command:
  gdrive_retain_command:
    url: https://homeassistant.local:1627/retain
    method: POST
    headers:
      accept: "application/json, text/javascript, */*; q=0.01"
      user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36"
    payload: '{"slug":"XXXXXX","sources":{"HomeAssistant":true,"GoogleDrive":true}}'
    content_type: "application/json"
    verify_ssl: false

ok… solved…
i made a sensor like this

- platform: template
  sensors:
    gdrive_last_bkup_slug:
      friendly_name: Gdrive last backup slug
      value_template: |-
        {%- for s in state_attr('sensor.backup_state', 'backups')
          if (state_attr('sensor.backup_state', 'last_backup') in s.date) %}
          {{s.slug}}{% if not loop.last %}
        {% endif %}
        {%- endfor %}

and used in the rest command like this:

rest_command:
  gdrive_retain_command:
    url: https://homeassistant.local:1627/retain
    method: POST
    headers:
      accept: "application/json, text/javascript, */*; q=0.01"
      user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36"
    payload: '{"slug":"{{ states("sensor.gdrive_last_bkup_slug") }}","sources":{"HomeAssistant":true,"GoogleDrive":true}}'
    content_type: "application/json"
    verify_ssl: false

hope this will help! @forums2012

is there a list of recommended or required add-ons to stop at backup? its not enabled by default so im guessing its uncommon but wanted to check. most of my add-ons are replaceable, but mosquito broker, ring-mqtt, and z-wave js to mqtt are all pretty critical and things i would Not want to set up from scratch again. Are any of those recommended to stop? any other common add-ons that are problematic for backups?

I use all those addons and have never needed to stop any of them before making a backup.

A while ago it was recommended to stop the MariaDB addon before creating a backup, but I believe that issue has since been resolved. However, I still have it set to stop before a backup since I never got around to changing the settings since it’s been working as is.

Hello, I have been using this add-on for over a year on my current setup and I am trying to change the Google drive account where my backups are saved but Google seems to be blocking something.

The currently configured account appears to still be working fine, the last backup was uploaded this morning at 3AM but when I try to change the account using both methods, I am receiving the same Google message when I get redirected to google to authenticate; (using the “authenticate with Google Drive” simple option) or authorize using client ID and secret (using the external domain method, fully configured on the new google account according to the instructions (https://github.com/sabeechen/hassio-google-drive-backup/blob/464a9e9c1bb362e247cb1411e8cab37183b09bed/LOCAL_AUTH.md)); I am always getting an Authorization Error from Google:

Authorization Error
Error 400: invalid_request

You can’t sign in to this app because it doesn’t comply with Google’s OAuth 2.0 policy for keeping apps secure.

You can let the app developer know that this app doesn’t comply with one or more Google validation rules.
Request Details
The content in this section has been provided by the app developer. This content has not been reviewed or verified by Google.
If you’re the app developer, make sure that these request details comply with Google policies.
redirect_uri: urn:ietf:wg:oauth:2.0:oob

Any ideas?

Thanks!

@spy_spirit Please see my response on github

@RickyFish Usually an when an addon doesn’t back-up correctly the addon developer fixes the issue, so there isn’t any one in particular I know of that still needs to be stopped. The feature was added to stop addons during backup before addons had the ability themselves to do something special during backup. I haven’t removed it because it still comes in handy every once in a while (ie new bugs) and some users just seem to like always using it anyway.

2 Likes

Hi @sabeechen
Thanks for the great addon.

I only recently discovered this add-on but I’m struggling to get the add-on to start (with latest version of HA installed).
It successfully installs and when I click start, it fails to start. I’ve tried restarting HA but the problem persists.
I’ve also tried uninstalling and re-installing the add-on - the problem still persists.

I have noticed that there is a red dot in the top right corner - as per pic below.
If I select all the options (start on boot, watchdog etc), click on start, they all go back to the off position.

The log can also be found below.
Hoping you can assist :slight_smile:


Hi @sabeechen
So after some digging, I discovered that Firefox was blocking the plugin from starting - I suspect it’s one of my Firefox add-ons.
I’ve set everything up with Chrome so all is great!
Thanks so much

The problem I reported of failed backup attempts is solved with zigpy 0.47.3 published on 14/7/22 and incorporated in Home Assistant Core 2022.7.5

1 Like

@sabeechen - Stephen the other thread (from May 2019) has become too long so thought will start a new one.

I recently updated to version 0.108.2 and seems that the add-on keeps failing due to “Google Drive is full” but at the same time shows correctly the free space on Google drive. See screenshot below & attached logs if it helps.

07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/addons/self/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/core/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/supervisor/info
07-27 20:58:51 INFO [backup.ui.uiserver] Starting server on port 8099
07-27 20:58:51 INFO [backup.ui.uiserver] Server started
07-27 20:58:51 DEBUG [backup.model.syncer] Sync requested by Coordinator
07-27 20:58:51 INFO [backup.model.coordinator] Syncing Backups
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/supervisor/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/6b242561/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/a8cbe17b/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/634fdf8b/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/55c7cadf/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/72c50e96/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/edc2f073/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/7e4991b8/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/72b42469/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/5427a552/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/e1e48c60/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/bb2d017b/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/0553a743/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/a78be02a/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/18e250fa/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/1a716069/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/369bcdec/info
07-27 20:58:51 DEBUG [backup.ha.harequests] Making Hassio request: http://supervisor/backups/fdf35aa1/info
07-27 20:58:51 DEBUG [backup.drive.driverequests] Making Google Drive request: https://www.googleapis.com/drive/v3/files/<redacted>/?fields=id%2Cname%2CappProperties%2Csize%2Ctrashed%2CmimeType%2CmodifiedTime%2Ccapabilities%2Cparents%2CdriveId&supportsAllDrives=true
07-27 20:58:51 DEBUG [backup.drive.driverequests] Making Google Drive request: https://www.googleapis.com/drive/v3/about?fields=storageQuota%2Cuser
07-27 20:58:51 DEBUG [backup.drive.driverequests] Making Google Drive request: https://www.googleapis.com/drive/v3/files/?q=%27<redacted>%27+in+parents&fields=nextPageToken%2Cfiles%28id%2Cname%2CappProperties%2Csize%2Ctrashed%2CmimeType%2CmodifiedTime%2Ccapabilities%2Cparents%2CdriveId%29&pageSize=100&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives
07-27 20:58:51 INFO [backup.drive.drivesource] Uploading 'Full Backup 2022-07-25 20:58:58' to Google Drive
07-27 20:58:51 DEBUG [backup.drive.driverequests] Starting a new upload session with Google Drive
07-27 20:58:51 DEBUG [backup.drive.driverequests] Making Google Drive request: https://www.googleapis.com/upload/drive/v3/files/?uploadType=resumable&supportsAllDrives=true
07-27 20:58:52 ERROR [backup.model.coordinator] Google Drive is out of space
07-27 20:58:52 INFO [backup.model.coordinator] I'll try again in an hour
07-27 20:59:01 INFO [backup.debugworker] Sending error report (see settings to disable)

Please see if there is any way to fix this and make the add-on work again.

Thanks.

I solved it by uninstalling the component and reinstalling it, you can try

Based on your screenshot it looks like you’re latest backup is around 30GB. You only have 14GB left in Drive.

2 Likes