This addon enables easy Home Assistant backup creation and sync to OneDrive.
- Set backup creation schedule
- Syncs backups to OneDrive (Personal Account only. OneDrive for business not currently supported)
- Recovery mode for loading backups back from OneDrive to Home Assistant
- Supports backup retention for removing older backups
- Support Home Assistant Persistent Notifications
- Includes Sensor Entities for Dashboards / Automations
This is a free addon but if you enjoy this addon and would like to support the development it >would be much appreciated :)
Installation Instructions
Configuration
Backup Location in OneDrive
OneDrive FreeSpace Sensor
Home Assistant Sensor
Restoring from backup
Security and Privacy
Feedback / Feature requests
If you've installed Add-ons before this will be pretty straightforward and you can skip reading thorugh all the steps below except the initial authentication parts in steps 7 and 8.
-
From the Home Assistant frontend navigate to the Add-on Store ( Settings -> Add-ons -> Add-on Store [bottom right])
-
Select the Repositories option from the 3-dot menu in the top right corner and add this repository url: https://github.com/lavinir/hassio-onedrive-backup
-
Reload the Add-on page (hard refresh might be required) and scroll down. You should now see a new section titled Home Assistant Onedrive Backup Repository that contains the OneDrive Backup addon.
-
Click Install and wait a few minutes for the addon to download
-
Before you are able to start the addon, you will be asked to set a password for your Home Assistant backups (I've currently made this mandatory for security best practices). Either navigate to Configuration in the addon menu on top or attempt to Start it (which will navigate to the Configuration section for you and ask you to input a Backup password)
-
Start the addon and wait a few seconds for it to start.
-
You will need to Authenticate with OneDrive one time to allow the addon access to a dedicated backup folder in your OneDrive account. (If you're interested in the addon permissions and the authentication flow you can see more details below under Security and Privacy). Open the Addon Logs from the Add-on menu on top and you should see the following lines: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ********* to authenticate.
-
Copy the code and navigate to the url as instructed. You will be asked to login to your Microsoft account and grant permissions to the App that will allow it to store your backups. .
After consent has been granted you're good to go (you can verify in the logs that authentication has indeed succeeded)
All configuration options for the addon can be found in the native Configuration section of the addon in Home Assistant.
When this settings is toggled on, the add-on will not perform any backups and sync mode will reverse from OneDrive back to Home Assistant. This will still respect the maximum local backups set and will try to sync back the latest backups that exist in OneDrive while remaining under the set limit.
See Restoring from backup for additional information on how to recover from a backup.
The maximum amount of backups to keep locally in Home Assistant
Note that the number of the actual backups can temporarly exceed the set maximum by one due to the fact deletion occurs only after a new backup is created.
The maximum amount of backups to keep in OneDrive
The backup creation frequency in days.
For setting a sub-day frequency you can use a number between 0 and 1, so for example if the value here is set to 0.5, the backup frequency will occur every 12 hours. You should avoid using a value less than 0.083 (~2 hours) as the current enforced minimum sync interval is once an hour.
NOTE: There is a bug in the Home Assistant UI that will light up the value in red (invalid) when you try to use a non whole number here. Ignore this and save the configuration with the value you want.
Name to use for the backups created by the add-on.
To avoid collision with backups created outside this addon please use a unique name here.
The password to use to protect the backups created and uploaded to OneDrive.
Currently this is mandatory to set as I don't think it makes sense to store these unprotected.
This allows you to set the timeout configured when calling the Home Assistant APIs.
This applies to how long your backups take to create. If you experience timeouts during backup creation, increase this value.
Enables persistent notifications in Home Assistant to notify of backup failures.
When enabled, a partial backup will be created without the media folder
When enabled, a partial backup will be created without the ssl folder
When enabled, a partial backup will be created without the share folder
When enabled, a partial backup will be created without the addons/local folder
This accepts a range of hours from 0 to 23 for which only during these hours will backups be performed. If a backup is required it will be performed at the first window allowed in the defined hours.
The format of this is one or more ranges seperated by a comma. A range is specified by a dash
Example:
0-2,10,21- [Allowed hours are 00:00-02:59, 10:00-10:59 and 21:00-23:50]
You need to toggle the "Show unused optional configuration options" to see it in the Configuration screen.
The add-on has specific permissions to a single folder in your OneDrive known as the App Folder. (More details can be found in the Security and Privacy section.)
The App Folder for the add-on is mapped to : [onedriveroot]/Apps/hassio-onedrive-backup
The add-on creates a native Home Assistant Sensor entity sensor.onedrivefreespace that will show you the amount of free space in your OneDrive account.
The add-on creates a native Home Assistant Sensor entity sensor.onedrivebackup which allows convinient visibility to the backup status as well as allows you to create automations on these values as needed.
There are 5 possible states for the sensor:
All backups are fresh and within the maximum set values both locally and on OneDrive. This is the optimal state for the sensor to be in.
Local backups are fresh and within defined limits, however this indicates possible staleness in the OneDrive backups.
Additional visiblity into the full backup state can be found in the Sensor Attributes below.
OneDrive backups are fresh and within defined limits, however this indicates possible staleness in the local backups.
Additional visiblity into the full backup state can be found in the Sensor Attributes below.
Syncing to OneDrive is in progress.
All backups (local and OneDrive) are outside the defined backup interval configured.
The sensor also exposes the following attributes:
Date of the latest backup that exists locally in Home Assistant
Date of the latest backup that exists in OneDrive
Number of backups that exist locally in Home Assistant
Number of backups that exist in OneDrive
When a backup upload is in progress this will show the progress of the upload.
When a backup download is in progress (Recovery Mode), this shows the progres of the download.
To restore a backup head to the Settings -> System -> Backups menu. From there you should see all your local backups. You can choose any one from the list and recover Home Assistant from them.
For backups in OneDrive only, you will first want to sync them back locally. See Recovery Mode below for details.
Recovery Mode can be enabled from the add-on configuration panel. Once enabled, the add-on will cease all backup creation and syncing from Home Assistant to OneDrive. Instead, it will attempt to sync back the latest backups from OneDrive to Home Assistant. The number of backups that will sync back will be capped by the amount of maximum local backups configured.
In case you cannot sync the backup you want because it is too old and you are unable to sync all the newer backups to Home Assistant because of storage capacity (or just prefer not to) you can manually download the backup from OneDrive and upload the backup from this screen by clicking the 3-dot menu on the top right and choosing the Upload Backup option.
Authentication with OneDrive uses Microsoft's Device Code Flow. At no point is the addon exposed to your account password. Once permission has been granted, a token is cached locally which is used for future authentications. The token only has access to a single special App Folder created by the Application and has no access to any of your OneDrive files outside of this dedicated folder. Granting access to the application does not grant access to me or anyone else access to this folder outside of the current flow for the add-on on your device.
The only things stored locally are:
- Backups (stored in Home Assistant and password protected)
- The authentication token mentioned above in Authentication
Outside the backups uploaded to your OneDrive account, no data is sent anywhere else.
If you use and like this addon and want to show support you could do so by starring the official Repo on GitHub or
For Bugs / Issues please open an Issue on GitHub
For new suggestions / feedback please use the official repo GitHub Disucssions