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

For anybody getting token expired errors, I sent a message to Dropbox support and got this answer:

Hi John,

Dropbox is in the process of switching to only issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find more information on this migration here.

Apps can still get long-term access by requesting “offline” access though, in which case the app receives a “refresh token” that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation.

For reference, while the creation of new long-lived access tokens is now deprecated, we don’t currently have a plan to disable existing long-lived access tokens. (If that changes, we will of course announce that ahead of time.) That being the case, you can continue using existing long-lived access token(s) without interruption, if you have any. Also, note though that after the change you won’t be able to create new long-lived access tokens.

While the change began on September 30th 2021, we’re releasing it gradually, so you may not have seen your app(s) affected until now. Once it applies to your app, it would apply regardless of the “Access token expiration” setting for your app, and that setting may no longer be available for your app.

Note that this is something that would need to be implemented by the programmer of the app though, so if you are not the programmer responsible for this integration, you may need to get an update from them to support this.

Regards,
Moe

Which led me to file this bug:

@danielwelch

Hi Daniel,

Thanks so much for creating this addon years ago. I have been using it successfully for a number of years, but just in recent months I am having the same problem as DavidFW1960 described in the post above.

It semes the scan all backups and the upload of any new backups to dropbox works. However when it triggers the keep_last option, it fails and does not delete any of the other backups from HA.

I am using version 1.3.0 of the Add-on and Home Assistant 2022.7.6.

Any ideas?

{"command":"upload"}
[Info] Received message with command upload
[Info] Uploading all .tar files in /backup (skipping those already in Dropbox)
 > Skipping already existing file "/ha-primary-backups/36d9bbae.tar"
 > Skipping already existing file "/ha-primary-backups/387eee62.tar"
 > Skipping already existing file "/ha-primary-backups/550ffb44.tar"
 > Skipping already existing file "/ha-primary-backups/5b1b5379.tar"
 > Skipping already existing file "/ha-primary-backups/7710fb3a.tar"
 > Skipping already existing file "/ha-primary-backups/9102a598.tar"
 > Skipping already existing file "/ha-primary-backups/aa39269a.tar"
 > Skipping already existing file "/ha-primary-backups/b9da8905.tar"
 > Skipping already existing file "/ha-primary-backups/ba2335ea.tar"
 > Skipping already existing file "/ha-primary-backups/cc05584e.tar"
 > Skipping already existing file "/ha-primary-backups/fd160b11.tar"
[Info] keep_last option is set, cleaning up files...
Traceback (most recent call last):
  File "/keep_last.py", line 47, in <module>
    main(args.number)
  File "/keep_last.py", line 15, in main
    snapshot_info.raise_for_status()
  File "/usr/lib/python3.6/site-packages/requests/models.py", line 939, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://hassio/snapshots

Same issue as @DavidFW1960

From what I can see, the issue is that it’s trying to go to /snapshots but this seems to have changed in Home Assistant (it’s tripped me up on some other addons too)

The location is /backups

If I go to:

http://homeassistant.local:8123/hassio/snapshots

I get redirected to:

http://homeassistant.local:8123/hassio/backups

Hope this helps

That was 2 years ago. This addon is dead. I’m using a script for this now

Lol oops, I saw Jul and thought it was this month!

I gave the Google Drive plugin a try instead, works like a charm