In this guide, I’ll show you how to automatically create Home Assistant backups and save them to Google Drive in 2021. To do this, we are using a community addon called Home Assistant Google Drive Backup. Home Assistant Google Drive Backup leverages Home Assistant’s snapshot feature to schedule snapshots as frequently or infrequently as you need.
For example, you can schedule:
- Multiple snapshots a day
- Weekly snapshots
- Daily, weekly, and monthly snapshots
If you find yourself updating Home Assistant often, I’d recommend at least daily snapshots. But if you’re more of a “set it and forget it” user, then you can probably get away with weekly or monthly backups.
Why should you backup to a cloud service?
You should always backup your important data and files in multiple locations. In the IT world, we call this the 3-2-1 backup rule. 3 copies of your data, stored on two different mediums, with one of those being offsite and offline.
This same strategy should apply to Home Assistant. Which you can definitely create your own snapshots and save locally, what happens if your computer crashes or gets stolen? What happens if you have a fire?
For those disaster recovery scenario’s, an automated and free backup solution is something every Home Assistant user should have setup.
To get started, all you need is a Google Drive account and have Home Assistant up at running. Google Drive provides you with 15gb of free storage, but if you need to upgrade to 100gb/mo, it’s only $1.99/mo.
The amount of storage you’ll need is going to depend on how large your snapshots are and how frequently you want to keep the backups. For example, if you’re taking 4 snapshots a day, and each snapshot is 250mb, you’ll retain backups for about 60 days with the free plan.
How To Install Hassio Google Drive Backup
This addon gets installed just like you’d install any other community project.
Step 1: Add Github URL to Add-On Store
- Log into Home Assistant. Navigate to Supervisor > Add-On Store.
- Click the 3 dots in the top right corner > Repositories.
- Paste this URL: https://github.com/sabeechen/hassio-google-drive-backup After a few moments, you’ll see that it was added successfully.
Step 2: Install
Click the Home Assistant Google Drive Backup repository. Then click Install. Installing everything will take a few minutes
Once installed, I recommend moving the 4 sliders to the on position. Then click Start.
Next, click the button that says “Open Web UI” or click Snapshots if you added to your sidebar.
Step 3: Integrate with Google Drive
Click the big blue button that says Authenticate with Google Drive. Choose the gmail address associated with your Google Drive account.
Grant habackup.io permission to create and upload to your folder.
The click Allow.
Then, simply click Send Credentials or copy and paste the authorization string to clipboard and paste in manually.
Step 4: Synchronize to Google Drive
Your snapshots with start syncing to a new Google Drive folder called Home Assistant Snapshots. You’ll notice that it automatically creates a new snapshot for you as well.
You can either let it backup all snapshots you currently have, or click Actions to delete any you don’t want backed up.
Step 5: Customize the Settings
The last step is to customize your snapshot frequency and retention. To do this, click Settings at the top.
In the 3 orange squares, you can customize:
- Number of snapshots kept in Home Assistant (be mindful of how large your SD card is!)
- Number of snapshots kept in Google Drive (be mindful of 15gb storage limit)
- Days between snapshots. If you want daily snapshots, choose 1. If you want weekly, choose 7.
I also recommend setting your snapshot time of day to a time of day before you’ll make any edits, like 4am, and password protecting your snapshots. You could then store your password as a secure note in Bitwarden. There’s a few other options below those, but those are the main ones you’ll want to change.
Lovelace Dashboard Card
This addon creates a few sensors that display the status of of your snapshots. If you’d like to create a card for your homepage dashboard, go to your Home Assistant homepage and then:
- Add Card.
- Scroll to the very bottom.
- Paste the code exactly as below.
type: conditional conditions: - entity: binary_sensor.snapshots_stale state_not: "off" card: type: markdown content: >- Snapshots are stale! Please visit the "Home Assistant Google Drive Backup" add-on status page for details. title: Stale Snapshots!`
The card will look like this:
Create Automation Alert if Backup Fails
There’s nothing worse than assuming your backups are working correctly, only to realize they weren’t backing up. This always tends to happen when you need them the most.
I highly recommend creating an automation to notify your phone if your backup job fails. To do this, go to:
- Configuration > Automations > Add Automation.
- Automation name: Send notification to Danny when Google Drive backups fail
- Triggers: Change to State
- Entity: binary_sensor.snapshots_stale
- From: Off
- To: On
- Action Type: Device
- Device: Your phone
- Action: Send a notification
- Message: Check your Home Assistant backups.
- Title: HA Backup Failed!