How to Back Up and Restore Your Home Assistant Server

Backing up your Home Assistant server is essential in case anything goes wrong. Here’s how to back it up and also how to restore a backup when needed.

Data loss is inevitable, and may occur due to hardware and software failures. However, with regular backups, you can restore the data and critical applications, such as Home Assistant, back to their original or last working state. Here we’ll explain a few different methods to create full and partial backups of your Home Assistant server on a local drive and cloud storage. You will also learn how to schedule automatic backups and use these backups to restore your Home Assistant server after a failure.

Ways to Back Up Your Home Assistant Server

There are two different ways in which you can schedule or create local and cloud backups of your Home Assistant server:

  • Use the built-in system backup options to create local backups.
  • Use the Home Assistant Google Drive Backup add-on to schedule local backups and upload them to the cloud (Google Drive) automatically.

Manually Create Home Assistant Backups on the Local Drive

You can create a full or partial backup of your Home Assistant Server on a local drive by following these steps:

  1. Log in to the Home Assistant server as an administrator.
  2. Go to Settings > System > Backups.
  3. Click the +Create Backup button.
  4. Enter a name for the backup.
  5. Choose the backup method, i.e. Full backup or Partial backup. You can also encrypt the backup by selecting the Password protection checkbox.
    create manual backups in home assistant server

  6. Click Create. This may take a while to complete.
  7. After some time, you will see your backup in the Backups list.
  8. You can click on the latest backup to download the backup copy on your system.

Schedule Automatic Home Assistant Backups

You can automate these manual backups by using the Hassio.Backup_Full or Hassio.Backup_Partial service. To do so, follow these steps:

  1. Go to Settings > Automations & Scenes.
  2. Click Create Automation and choose Start with an empty automation.
  3. Click +Add Trigger and choose Time. Enter a time in HH:MM:SS.
  4. Click +Add Action and choose to Call a service.
  5. In the Service, search for the Home Assistant Supervisor: Create a full backup or the Home Assistant Supervisor: Create a partial backup option.
  6. You may enter a name for the backup or keep it as the default, and enter the password to keep the backups encrypted.
  7. Click Save.
    schedule automatic backups in home assistant server

  8. Give the backup automation task a name with a description and click Save.

Alternatively, you can click on the three dots at the top in the automation window, choose Edit in YAML, paste the following code to create an automation for backup, and click Save.

alias: Auto-Backups
description: Auto backup service to create a "Full Backup" everyday at 2:00AM.
- platform: time
at: "02:00:00"
condition: []
- service: hassio.backup_full
mode: single

edit the backup automation task in yaml

This will run the backup service and create a full automatic backup of the Home Assistant Server at 2:00 every day.

Alternatively, you can install the Samba Backup add-on to schedule the backups and set up a network-shared folder on Ubuntu with Samba to automatically copy the backup to the shared location.

Schedule Automatic Home Assistant Backups and Upload Them to Google Drive

Using the Home Assistant Google Drive Backup add-on, you can enable automatic backups of your Home Assistant Server. The add-on also automatically uploads the Home Assistant backups to Google Drive and cleans up the old backup so that the server or Google Drive doesn’t run out of space.

To install and set up automatic cloud backups to Google Drive in your Home Assistant Server, follow these steps:

  1. In the Home Assistant, go to Settings > Add-ons and click the Add-In Store button.
  2. Click the three dots at the upper right and choose Add Repositories.
  3. Paste the link and click Add.
    add the home assistant google drive backup repository

  4. Then reload the current page and search for Home Assistant Google Drive Backup add-on.
  5. Click on the add-on and then click Install. Wait for a few minutes and let it finish.
  6. Then click Start. After a few seconds, click Open Web UI. This opens the Home Assistant Google Drive Backup web user interface.
    install and start home assistant google drive backup add-on

  7. Click Settings and enter the maximum number of backups you want to create and store in Home Assistant and Google Drive. Also, you can choose whether to keep the uploaded backup in Home Assistant or delete it after upload, and whether to delete the old backup before creating a new one. We kept them disabled.
  8. Scroll down and choose the number of days between the backups, and the time, and enter the password to secure the backups. Keep everything else as default and click Save.
  9. Click Authenticate with Google Drive, log in to your Google Account, and authorize. You will get an authorization code string. Copy the code string, go back to the Home Assistant Google Drive Backup page, and paste it into the empty field. Click Save.
    authorize home assistant google drive backup service

  10. You will be redirected to the default backup status page where you can create new backups, view backup progress, upload progress, etc.
    home assistant google drive backup creating automatic backups and uploading to google drive

Once you have configured the Google Drive Backup for Home Assistant, you don’t need to worry about Home Assistant backups anymore. It also offers several customization features that you can explore and use.

Steps to Restore Home Assistant Server Backups

If something goes wrong with your Home Assistant Server, such as damage to your Configuration.yaml file or if the servers start acting up, you can install the Home Assistant Server on a Raspberry Pi or Docker and then upload the last backup to restore the Home Assistant to its normal working state.

You can upload and restore the backup just after Home Assistant finishes the installation and before the initial setup where you create an account. Instead of signing up…

  1. Click the Alternatively, you can restore from a previous snapshot option on the setup page. It will open the file explorer window.
    restore failed home assistant server from backup

  2. Choose the last downloaded backup from Home Assistant or Google Drive and then click Restore Selected.
    select upload and restore home assistant server from backup

You may also upload the backup later, after the initial setup:

  1. Go to Settings > System > Backups.
  2. Click on the three dots at the top and choose Upload Backup.
    upload and restore home assistant server from local or google drive backup

  3. Browse and choose the last backup you have downloaded from the Home Assistant Server or Google Drive to restore the server.

Back Up Now!

Backups are crucial, especially when you run a critical application, such as a Home Assistant server for your smart home. If you are using the Home Assistant server, you know the effort it takes to find the best configurations and settings to add and make your integrations, add-ons, smart devices, entities, automation, scripts, scenes, and so on work. We can’t even think of setting up the Home Assistant server from scratch. If you feel the same, back up now!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *