Created new add-on to backup snapshots to Google Drive

After ignesting code I get only

Server Error (500)

I use duckdns plugin for ssl

I was getting a similar error. I have an ASUS router and I had to forward port 8055 to 8055 to the IP address of my HASSIO device. After doing that it works for me.

Hope this helps

Tried the same, no success

Iā€™m getting the following error when trying to execute it in browser

{"errorMessage": "<HttpError 404 when requesting https://www.googleapis.com/drive/v3/files?q=name%3D%27bda8c705.tar%27+and+%27Some_Google_Drive_Unique_Opaque_Folder_ID%27+in+parents+and+trashed+%3D+false&spaces=drive&fields=files%28id%2C+name%29&alt=json returned \"File not found: .\">"}

Is that File not found referring to missing backup file? I could not verify whether the snapshots are actually ending to such a folder on Pi (newbie with Raspberry ā€¦ still trying to get understanding where such a folder should be)

It looks like you didnā€™t set the backupDirID in your configuration per these instructions.

Did you find any solution? Iā€™m getting the same error

Works perfect!
It would be great if another endpoint saved the latest response from the backup get request, so that we could make rest sensors to quickly see things like backupTimestamp, backedUpCount and the other interesting stuff in the response!

In the end I did not find any typos in the backupDirID nor elsewhere. Ended up redoing all the steps again from the beginning (not reinstalling the addon) and then it started to work. Cannot even guess whether human error or some delay in the authorization etc. was the issue

Ahh! Based on what you just said, and based on the content of error that you shared earlier (I remember seeing my dummy value for the backupDirID in that error message), Iā€™m guessing that your original edits to the configuration were not picked up by my add-on. Itā€™s likely that restarting the add-on caused it to finally pick up your edits. Sort of a guess. And that shouldnā€™t happen. But Iā€™m glad itā€™s working for you now.

@samccauley thanks and respect for the addon! worked perfect for me. imho it should be part of the official repo.

1 Like

Hi @samccauley

Iā€™m getting this error when is launched by automation:

2019-02-15 03:30:05 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.backups_en_google_drive. Unknown error for call_service at pos 1: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 955, in _create_direct_connection
    traces=traces), loop=self._loop)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 825, in _resolve_host
    self._resolver.resolve(host, port, family=self._family)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/resolver.py", line 30, in resolve
    host, port, type=socket.SOCK_STREAM, family=family)
  File "uvloop/loop.pyx", line 1459, in getaddrinfo
socket.gaierror: [Errno -3] Try again 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/rest_command.py", line 105, in async_service_handler
    headers=headers
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 476, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 522, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 854, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 959, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host myDomain:8055 ssl:None [Try again]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/automation/__init__.py", line 380, in action
    await script_obj.async_run(variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 85, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1130, in async_call
    self._execute_service(handler, service_call))
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1152, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/rest_command.py", line 118, in async_service_handler
    _LOGGER.error("Client error %s.", request.url)
UnboundLocalError: local variable 'request' referenced before assignment

It has happened three consecutive nights. The next day I launch the automation manually and everything works correctly. Do you have any idea what may be happening?

Thanks

It sounds like a problem with how your automation is setup. Hereā€™s my setupā€¦

I have my automation setup like this:
- id: '1541263656718'
  alias: Run Google Backup
  trigger:
  - at: 02:00:00
    platform: time
  condition:
  - condition: time
    weekday:
    - mon
    - wed
    - fri
  action:
  - service: rest_command.google_backup

The automation uses a REST command that I setup like this:
rest_command:
  google_backup:
    url: 'http://localhost:8055/gb/doBackup'
    timeout: '300'

The timeout value is important. It doesnā€™t work with shorter/default timeout.

2 Likes

I have a timeout of 300 set, but as an Integer, not String.

Maybe thatā€™s the problem. Here is my automation:

- id: '1550049006025'
  alias: Backups en Google Drive
  trigger:
  - at: 06:30:00
    platform: time
  condition: []
  action:
  - service: rest_command.google_backup

In the configuration.yaml I have this:

rest_command:
  google_backup:
    url: !secret url_google_backup (myDomain.duckdns.org)
    timeout: 300

Hi,
According to the manual, the doBackup service would send a JSON response. How can I get this data?
I would like to send a notification with the content of it.

it has stop working and for some reason im getting this in logs

Segmentation fault (core dumped)

what that means

im using 0.88.0b2 version so im wondering if there was any changes cause this addon use to work in other versions

The JSON is returned in the HTTP response. If you use a tool like Postman, for example, youā€™ll see the response. I donā€™t know that Home Assistant does with the response, though.

Update to version 1.5.0. Iā€™m now publishing an MQTT event with the JSON in it.

Try version 1.5.0. Iā€™m not publishing an MQTT event with the JSON response in it.

1 Like

Wonderful!