Add-on: Home Assistant Google Drive Backup

Thats what happens when you create something so awesome! Thank you for your contribution to the HA community :smile:

4 Likes

@sabeechen I just started using your add-on tonight. I recorded my setup process, so of course I’ll be making a video very soon. I’ll give you a preview when I’m about done so you can tell me what I missed or did wrong.
Great work!!!

6 Likes

Awesome! I’m pretty familiar with your channel, without some of your videos I’d probably still be trying to figure out the right setoption commands for my tasmota switches :slight_smile:
Feel free to send me something to review, I should normally be able to get back within the day.

1 Like

A great add-on. Cannot install on my hassio on NUC running Hassio in a docker on Ubuntu. Also have a version of hassio in a docker on my Raspberry. Installs just fine.
On the NUC I think there are problems creating the virtual network connected to the docker. The add-on cannot find Google drive. Problems with DHCP / DNS or?
Anyone installed successfully on a NUC running Ubuntu.
The log file says it cannot connect to http://0.0.0.0:1627. Of course not, but why can’t it find the ip of the hassio installation

ERROR log2019-05-04 18:46:46,582 INFO Loading config from /data/options.json
/usr/lib/python3.6/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /data/credentials.dat: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
2019-05-04 18:46:46,601 INFO Starting server on port 8099
2019-05-04 18:46:46,602 INFO Starting server on port 1627
2019-05-04 18:46:46,602 INFO [04/May/2019:18:46:46] ENGINE Bus STARTING
2019-05-04 18:46:46,705 INFO [04/May/2019:18:46:46] ENGINE Serving on http://0.0.0.0:8099
2019-05-04 18:46:46,811 INFO [04/May/2019:18:46:46] ENGINE Serving on http://0.0.0.0:1627
2019-05-04 18:46:46,812 INFO [04/May/2019:18:46:46] ENGINE Bus STARTED
2019-05-04 18:46:46,812 INFO Server started
2019-05-04 18:47:04,817 INFO Saving new Google Drive credentials
2019-05-04 18:47:10,733 ERROR
Traceback (most recent call last):
File “/app/backup/engine.py”, line 158, in doBackupWorkflow
self._checkForBackup()
File “/app/backup/engine.py”, line 397, in _checkForBackup
self._syncSnapshots()
File “/app/backup/engine.py”, line 328, in _syncSnapshots
self.folder_id = self.drive.getFolderId()
File “/app/backup/drive.py”, line 199, in getFolderId
return self._findDriveFolder()
File “/app/backup/drive.py”, line 207, in _findDriveFolder
for child in self._iterateQuery(q=“mimeType=’” + FOLDER_MIME_TYPE + “’”):
File “/app/backup/drive.py”, line 228, in _iterateQuery
request = self._drive().files().list(
File “/app/backup/drive.py”, line 83, in _drive
return build(DRIVE_SERVICE, DRIVE_VERSION, credentials=self.creds)
File “/usr/lib/python3.6/site-packages/googleapiclient/_helpers.py”, line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File “/usr/lib/python3.6/site-packages/googleapiclient/discovery.py”, line 224, in build
requested_url, discovery_http, cache_discovery, cache, developerKey)
File “/usr/lib/python3.6/site-packages/googleapiclient/discovery.py”, line 274, in _retrieve_discovery_doc
resp, content = http.request(actual_url)
File “/usr/lib/python3.6/site-packages/httplib2/init.py”, line 1926, in request
cachekey,
File “/usr/lib/python3.6/site-packages/httplib2/init.py”, line 1595, in _request
conn, request_uri, method, body, headers
File “/usr/lib/python3.6/site-packages/httplib2/init.py”, line 1508, in _conn_request
raise ServerNotFoundError(“Unable to find the server at %s” % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at www.googleapis.com

2019-05-04 18:47:10,733 ERROR A retry will be attempted in 10 seconds
2019-05-04 18:49:19,034 INFO Sending error report (see settings to disable)
2019-05-04 18:51:34,424 ERROR Unable to reach Home Assistant. Is it restarting?
2019-05-04 18:52:04,508 INFO Home Assistant came back.

Can I just add a testimonial of how amazing @sabeechen has been. :slight_smile:

The attention to detail to the addon is far beyond imagination!
And the open-ness to suggestions and the prompt-ness with the updates is awesome as well.

1 Like

@sabeechen I don’t know if this is the right place for this or not but I am thinking now that you have a grasp on how to “sync” folders b/w hassio and google drive, is there a way you could slightly modify and stitch up another addon to sync folders (I am thinking this could be a good sync and 30 day history for camera images)

So instead of /backup folder it would be a selectable folder like “/www/camera/” and the jpg keep uploading to gdrive.

Sorry if it is too much to ask, but was a shower thought so I thought why not pass it by an amazing developer! :slight_smile:

This add-on is pretty tightly coupled to specifically handling snapshots, but you might be able to cobble that together with samccauly’s Google Dive add-on:


I haven’t tried what you’re proposing specifically, but if I’m reading their docs right you can point it at any folder and specify a pattern of files to look for and backup.

Added this addon this evening and it is excellent.

Is there a way to change the Web UI URL as I have several instances of HA on my network with the same port number but different IP addresses ? I want to override the URL to an IP address instead.

I know I could use an iframe but would also like to be able to change it in the addon.

I run it on NUC8, Ubuntu 18.04 and Docker.
I had some general DNS issues with Ubuntu and Docker in the beginning which I could sort out.
But there seem to be specific DNS issues with this addon, a related open Issue is already existing on GitHub.

@BertrumUK you can change the port the addon runs at on the addon page in Hassio (this is the same for any addon), but there isn’t a way to change the path the webserver UI serves at. I might be misunderstading what you’re trying to do.

@Bluhme You’re definitely running into the same DNS issues as everyone else in the issue @eXtatic pointed out. I’ll keep posting there about it until I’m able to find a workaround. The message you see about 0.0.0.0:1627 is correct behavior for the addon, the 0.0.0.0 just indicates its serving on whatever ip address is available inside the docker container.

That’s a shame, instead of using https://hassio.local:1627 I would prefer to use https://192.168.0.50:1627 as the hassio.local address doesn’t always work on my router.

You should be able to do exactly that. I meant that you can’t change the path (the part after “:1627/”). Any thing that resolves to the correct IP address including the IP of the machine running Home Assistant should work (though you’ll run into certificate/hostname problems if you’re using SSL). Is that not working?

No my router can be a bit flakey and the url doesn’t work - I manually change the page to the IP address and then I am in but from clicking on the Web UI link I cannot get the page to show without adding the IP address.

Its a very minor issue that I can work around easily enough.

This add-on is awesome! Really easy to configure, and with great docs! - Thankyou @sabeechen

1 Like

Hi @sabeechen,
Thank you for this addon, this is one of the addons I’m fond of since its made my life so easy since i constantly make loads of changes and this helps me a ton to backup quick and check for success.

I wanted to check if there are states for the snapshot_backup sensor, so that i can track the status and send updates to my phone, right now it doesn’t change its state, i think its set to change only on “failure” is it possible to have a state for “uploading” or “waiting” and one for successful on the same sensor?.

im looking to make the below work, the nodered is for a ticker in my office.

- alias: Snapshots uploaded
  id: 'snapshots_uploaded'
  trigger:
  - platform: state
    entity_id: sensor.snapshot_backup
    from: 'waiting' #or uploading status
    to: 'backed_up' # or successful_backup
  condition: []
  action:
  - service: notify.iphones
    data_template:
      title: Snapshots Upload Success
      message: Backup Successful today {{ now().strftime('%Y-%m-%d %H:%M') }}

That sensor has 3 states, but I don’t think they’ll help for what you want

  • waiting: Waiting for you to connect the add-on with Google Drive
  • backed_up: Everything is up-to-date
  • error: there was a problem backing up.

You’ll probably want to look at the attributes for the sensor, which has a lot more detail. It includes:

  • last_snapshot timestamp of the last snapshot (including a pending snapshot)
  • snapshots a list of all the snapshots present, each entry has
    • name - The name you gave it
    • date - The date you created it
    • status - The status you see for the snapshot it in the web-ui

To configure what you’re trying to accomplish, I think you could do the following.

  • When last_snapshot changes, it means a snapshot has started.
  • When a snapshot with status=='Backup Up' has the same date as last_snapshot, it means a snapshot was created and backed up.
  • When the sensor state==error it means the backup failed.

You’d need to either write the logic in node-red (where you write arbitrary code) or create some tricky template sensors to do everything in HA. Honestly though, I’d recommend just alerting on the binary_sensor.snapshots_stale sensor. With a setup like this you’re likely to get a lot of noise from transient network errors.

1 Like

Hey, good one… let me give it a shot. I was more interested in the state on the web UI where the state is evident as it processes backup, but for now just the last snapshot logic seems to fit my purpose.

Or i could just run a message at a particular time when i’m starting backup and check it with the sensor for “error” status before publishing.

Thanks again for your time :slight_smile:

Another option, if you really want detail, is to poll http://hassio.local:1627/status. It returns a json object with, basically, the full state of the UI. The web UI functions almost entirely by polling this endpoint every 5 seconds. Be warned though, I don’t expect anything significant about the structure of it to change, but I’ll likely make modifications to what it returns the UI evolves in the future since its not really part of the “official” API of the addon.

That would be easy on me for now, i tried the link and it returns 404 after login.

## 404 Not Found

The path '/status' was not found.

Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/cherrypy/_cprequest.py", line 628, in respond self._do_respond(path_info) File "/usr/lib/python3.6/site-packages/cherrypy/_cprequest.py", line 687, in _do_respond response.body = self.handler() File "/usr/lib/python3.6/site-packages/cherrypy/lib/encoding.py", line 219, in __call__ self.body = self.oldhandler(*args, **kwargs) File "/usr/lib/python3.6/site-packages/cherrypy/_cperror.py", line 414, in __call__ raise self cherrypy._cperror.NotFound: (404, "The path '/status' was not found.")

Powered by [CherryPy 18.1.1](http://www.cherrypy.org/)

My mistake, its actually http://hassio.local:1627/getstatus