Hass.io Add-on: Upload hassio snapshots to Dropbox

Me too! I’m unfamiliar with Python, but can offer help on JavaScript…

This is awesome! I would love to see it optionally delete the local copy… and maybe only keep 3-5 days worth.

Yes it is and works brilliantly. As you say it would be the icing on the cake to delete oldest backups and keep ‘x’ in HA itself as you can always restore from Dropbox. You could even restore a backup to HA from dropbox… ah… Nirvana… but realistically, it’s not something you would do often enough for it to be a nuisance doing it manually IMO.

I had wrong automation, here is my working config for weekley backup:

- alias: Snapshot 3AM
  trigger:
    platform: time
    at: '3:00:00'
  condition:
    condition: time
    weekday:
      - sun
  action:
  - service: hassio.snapshot_full
    data_template:
      name: Automated Backup {{ now().strftime('%Y-%m-%d') }}
- alias: Upload dropbox 4AM
  trigger:
    platform: time
    at: '4:00:00'
  action:
  - service: hassio.addon_stdin
    data_template:
      addon: 7be23ff5_dropbox_sync
      input: {"command":"upload"}
3 Likes

I get the following error in the add on log
[Info] Received message with command upload
[Info] Uploading all .tar files in /backup (skipping those already in Dropbox)
Error loading data from /etc/uploader.conf…
It is recommended to run ./dropbox_uploader.sh unlink

So, with the following config I get errors, but it does create a snapshot with the standard hex filename:

- alias: Daily snapshot at 3 AM
  trigger:
    platform: time
    at: '7:48:00'
  action:
  - service: hassio.snapshot_full
    data_template:
      name: automated backup {{ now().strftime('%Y-%m-%d') }}


- alias: Daily upload to dropbox at 5 AM
  trigger:
    platform: time
    at: '8:00:00'
  action:
  - service: hassio.addon_stdin
    data_template:
      addon: "7be23ff5_dropbox_sync"
      input: {"command":"upload"}
2018-03-01 07:53:00 ERROR (MainThread) [homeassistant.components.hassio.handler] Timeout on /snapshots/new/full request
2018-03-01 07:53:00 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall hassio.snapshot_full: name=automated backup 2018-03-01>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/hassio/handler.py", line 137, in send_command
    X_HASSIO: os.environ.get('HASSIO_TOKEN', "")
  File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 104, in __iter__
    ret = yield from self._coro
  File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 277, in _request
    yield from resp.start(conn, read_until_eof)
  File "/usr/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 624, in start
    (message, payload) = yield from self._protocol.read()
  File "/usr/lib/python3.6/site-packages/aiohttp/streams.py", line 554, in read
    yield from self._waiter
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 237, in result
    raise CancelledError
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/hassio/__init__.py", line 189, in async_service_handler
    _LOGGER.error("Error on Hass.io API: %s", ret['message'])
TypeError: 'NoneType' object is not subscriptable

This add-on worked for me out of the box. Thanks!

My one suggestion is that the date, time and hassio version is prepended or appended to the filename.

Try just using data instead of data_template. See how that goes.

I get the same type of error, but the snapshot is made anyway. So it works with the error, which is fine by me :smiley: Thanks for the great plugin!

I got one question/suggestion: is it possible to show the date of the latest (successful) uploaded backup in Hassio frontend?

Is it possible to exclude some files? My log is too big

2 Likes

Has anyone managed to solve the issue of cleaning up backups?

I’ve got mine being copied off to a remote server which works fine and deleting the files from the backup shared directory… but it seems that HASSIO keeps a database reference somewhere as well…

For example if I look at my snapshot page I can still see all the previous snapshots - obviously if I click on any of them they are now 0Mb in size and won’t restore.

Although in writing this I’ve just realised you can’t really upload a snapshot back to HASSIO via the webui and restore it… which almost makes copying them off pointless.

Has anyone tried restoring a snapshot that was copied off previously?

Any ideas on cleaning up the snapshot page?

They have just put a refresh symbol back in so you can use that or do:
hassio sn reload
from a command line/terminal. (not update! Doh!)

This is also how you would do a restore - copy it back and refresh the list and restore.

1 Like

Ah yes, I see it now, perfect!. Thanks DavidFW1960

Per several requests, I’ve added the ability to remove old snapshots with the new keep_last option in version 1.1.0, which should be available today. If this option is set to a number, the add-on will keep only that number of add-ons locally; the rest will be deleted via calls to the Hassio API. Of course, before being deleted, the snapshots are uploaded to Dropbox. Obvious disclaimer: this works perfectly in my testing, but be careful in your initial testing as you’re dealing with deleting snapshot files.

1 Like

Works great Daniel. Thanks for this - it rocks. An automation to create a snapshot and your addin to copy to Dropbox and delete old snapshots. Excellent. It also seems to update the snapshot list in the hassio>snapshots too. Great job mate.

Good update! But you need to fill in a number for keep_last, otherwise the plugin won’t start (without giving any error in the log). Confused me for a bit, but works great!

How about my previous suggestion/remark? “is it possible to show the date of the latest (successful) uploaded backup in Hassio frontend?”

I think displaying information in the Home Assistant front end is beyond the scope of this (or any) add-on. I can’t think of a way to make this info readily available to a front-end sensor via the add-on off the top of my head, any suggestions?

As for the keep_last parameter, I’ll change it to optional in a bug fix release.

1 Like

BUmp, any ideas?

I get the following error in the add on log
[Info] Received message with command upload
[Info] Uploading all .tar files in /backup (skipping those already in Dropbox)
Error loading data from /etc/uploader.conf…
It is recommended to run ./dropbox_uploader.sh unlink

Sounds like a problem either with writing your Oauth token or with reading it. I’d uninstall and reinstall and hope that fixes it. If it persists, I’d guess it’s a problem with the token configuration in your instance of the add-on or something.

I did reinstall it but to no avail:
Below my configuration (token is changed of course)

{
“oauth_access_token”: “AAA-hzgAQASDSADSADB-8UKiasdfYlB3UW6-a5zsdaffasdJCG6Lx1V-lNKb-FnTR>”,
“output”: “/Home-Assistant-John/”,
“keep_last”: 2
}

Do you spot any mistakes?

P.s. for some reason i had to delete the < sign before AAA in order for it to show the token.