Automatic Backups of Home Assistant

One of the most important critical things to have on a large project such as home automation is a way to back up all of your configurations and files that you have spent countless hours working on. Home Assistant has a built in manual backup system that creates a complete backup of everything, but it is manual. If you are forgetful like me, then you can sometimes go weeks or months before you remember to create a backup. Even if you do remember to backup regularly, those backups are still located on the same system that you are trying to protect, so if, for example, a SD card fails, you might lose those backups too.

I recently discovered a plugin for Home Assistant that automatically creates a backup and stores it on Google drive for you. This plugin is very easy to set up and use, and once working, you can forget about backing up your system and start working away at making your system even better.

This plugin is written by sbeechen on Github (Link). They provide full instruction on how to add the plugin on the page, but I will provide a summary on this post.

Installing the Repository

The first step is to add the third party repository to Hass-IO, so it knows where to get the plugin from.

In your Hass-IO webpage, go to the Hass-IO admin page, then navigate to the Add-On Store tab at the top:

At the top of that page, there is a Repositories Section where we can add the Github link to the “Add new repository by URL” block.

https://github.com/sabeechen/hassio-google-drive-backup

Once you copy the link and select Add, the new repo should show up on your page.

Installing the Plugin

Scroll down to the bottom of the Add-Ons page and you should find the new Google Drive Backup plugin.

Select the plugin and once on the page, select install. Once installed, we will want to edit the config to meet out needs. Below is the config that I am using:

{
  "max_snapshots_in_hassio": 2,
  "max_snapshots_in_google_drive": 5,
  "days_between_snapshots": 1,
  "use_ssl": false,
  "snapshot_time_of_day": "00:00",
  "send_error_reports": true
}

With this config, I will keep the last 5 backup snapshots in google drive, and the latest 2 in local storage. The system will create a backup at midnight every single night, so at the latest, you only lose 24 hours of data.

Once the configuration has been set and saved, we can scroll back up to the top of the page and start the plugin.

Connecting the plugin to Google

At the top of the plugin page, there is a “Open Web Ui” button. Clicking this will go to the main page of the plugin where we can link our google account. Depending on your Google account, you may want to be careful what account you link the plugin to, as the snapshots can take up a bit of space depending on how much you have on Home Assistant. On the Web UI page, there is a “Authenticate with Drive” button near the top. Follow the instructions to link your google account.

What Now?

Now that everything is linked, we can sit back and watch as our hard work is saved automatically for us to the cloud. If something goes wrong and we need to recover our snapshot, all we need to do is install a fresh copy of home assistant, navigate to the snapshots section and select restore. Easy Peesy.

The plugin also adds a new sensor to Home Assistant that gives a status of our backups, so if anything goes wrong and the backups stop, we can trigger off of that to notify us.

Leave a Reply