Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Upload your Home Assistant backups to Dropbox.

License

Notifications You must be signed in to change notification settings

mikevansighem/dropbox-backup

Repository files navigation

Home Assistant add-on: Dropbox backup

Last commit Commits per month License GitHub Workflow Status GitHub issues GitHub release (latest by date)

Supports armhf Architecture Supports armv7 Architecture Supports aarch64 Architecture Supports amd64 Architecture Supports i386 Architecture

Upload your Home Assistant backups to Dropbox.

📄 About

This add-on allows you to upload your Home Assistant backups to your Dropbox, keeping your backups safe and available in case of hardware failure. Uploads are triggered via a service call, making it easy to automate periodic backups or trigger uploads to Dropbox via script as you would with any other Home Assistant service.

This add-on is inspired by Dropbox Sync from Daniel Welch. Major thanks for his work!

⤵️ Installation

  1. Go to the Supervisor add-on store in Home Assistant.
  2. Click on the "three-dots-menu" and choose Repositories.
  3. Add this repository to your Home Assistant instance: https://github.com/mikevansighem/dropbox-backup.
  4. Install the Dropbox backup add-on.
  5. Configure the add-on with your Dropbox OAuth Token and desired output directory (see configuration below).

🏗 Configuration

Generate Dropbox access token

To access your personal Dropbox, this add-on requires an access token. Follow these steps to create an access token:

  1. Go to Your Dropbox apps.
  2. Click on Create App.
  3. Select Scoped Access and choose between full or app folder only access.
  4. Give your app a unique name and click on Create App.
  5. Now your app is created go to the permissions tab and tick files.metadata.write.
  6. Back on the settings tab, go to "Generated access token" and click Generate.
  7. Copy the access code for use in your configuration.

Setup the add-on

Once you have created the token, copy it into this add-on's configuration under the oauth_access_token label.

Parameter Required Description
oauth_access_token Yes The "app" access token you generated above via the Dropbox UI.
output No The target directory in Dropbox to which you want to upload. If left empty, defaults to /, which represents the top level of directory of your Dropbox.
keep_last No If set, the number of backups to keep locally. If there are more than this number of backups stored locally, the older backups will be deleted from local storage after being uploaded to Dropbox. If not set, no backups are deleted from local storage.
preserve filename No If set to true the backup filename will remain the original slug e.g. d6f0919b.tar otherwise the files will be renamed to the backup name e.g. My Backup 2020-01-23.tar.

Example configuration:

{
  oauth_access_token: "<YOUR_TOKEN>"
  output: "/hasssio-backups/"
  keep_last: 2
  preserve_filename: false
}

🚀 Usage

Dropbox Sync uploads all backup files (specifically, all .tar files) in the Home Assistant /backup directory to a specified path in your Dropbox. This target path is specified via the outputoption. Once the add-on is started, it is listening for service calls.

After the add-on is configured and started, trigger an upload by calling the hassio.addon_stdin service with the following service data:

service: hassio.addon_stdin
data:
  addon: 782428ea_dropbox-backup
  input:
    command: upload

This triggers the dropbox_uploader.sh script with the provided access token. You can use Home Assistant automations or scripts to run uploads at certain time intervals, under certain conditions, etc.

A sample automation can be found here. To use it simply create a new automation and copy the YAML.

📝 License

This add-on is covered under the MIT license refer to LICENSE.md for details.