Backup your snapshots to Dropbox

I have created a small hassio addon for uploading snapshots to Dropbox.

After having problems with hassio-dropbox-sync (which otherwise I hear works for many people and seem great), I created a pure Python version to solve my problems. However, I wanted to share it and see if it would be useful for anyone else.

You can find the code here: https://github.com/d0ugal/hassio-dropbox-upload

Add the above address in Hassio addon repos. and install. Then configuration is very simple…

{
  "access_token": "DROPBOX TOKEN",
  "dropbox_dir": "/snapshots",
  "keep": 10,  # keeps the 10 most recent snapshots
  "mins_between_backups": 60  # Checks for new snapshots every hour
}

Contributions, feedback and ideas are very welcome! I have been using it for a couple of months now and it has gotten to a point of being fairly stable.

2 Likes

Do I have to create the folder in my Dropbox, or will the add-on do it if it doesn’t exist?
Do I need the “password:” line if I don’t use a password in my snapshots?
I am a total newb with Automations, but don’t they all require an “id:” line?
Your sample automation generates this config error:

Invalid config for [automation]: [trigger] is an invalid option for [automation]. Check: automation->action->1->trigger. (See /config/configuration.yaml, line 215). Please check the docs at https://home-assistant.io/components/automation/

Also, the add-on crashes. Here’s what’s in the log file:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/app/dropbox_upload/__main__.py", line 52, in <module>
    main(config.DEFAULT_CONFIG)
  File "/app/dropbox_upload/__main__.py", line 25, in main
    dbx.users_get_current_account()
  File "/usr/lib/python3.6/site-packages/dropbox/base.py", line 4245, in users_get_current_account
    None,
  File "/usr/lib/python3.6/site-packages/dropbox/dropbox.py", line 274, in request
    timeout=timeout)
  File "/usr/lib/python3.6/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
    timeout=timeout)
  File "/usr/lib/python3.6/site-packages/dropbox/dropbox.py", line 456, in request_json_string
    raise BadInputError(request_id, r.text)
dropbox.exceptions.BadInputError: BadInputError('4044fd13903174e41502c49321b125de', 'Error in call to API function "users/get_current_account": The given OAuth 2 access token is malformed.')

@hoangcv18 Thanks for this! Question: the name of the backup gets changed? I only get strange names in my dropbox folder.

This is so underrated. I loved your approach! Easy to install and setup.

Other methods were annoying and weren’t working for me either.

Thank you!

can you do this to a nas (synology)?

@hoangcv18 thanks for sharing this! Upload works very well.

I experienced the same, i have configured as follow and now it’s working fine:

{
  "access_token": "<MY_TOKEN>",
  "dropbox_dir": "/Hassio snapshots",
  "keep": 10,
  "mins_between_backups": 60,
  "filename": "snapshot_name",  ## <--- THIS DID THE TRICK
  "debug": false
}