Backups and Restores
The great thing is that backups are part of HA, and depending on the type of installation, it backs up only itself or, in the case of HassOS / Supervised version, it can also back up add-ons.
The name of automatic backups includes the version number of Home Assistant for which it is created, and in the current version, it cannot be changed.
Automatic Backups
In the long term, you should not rely on manual backups but rather choose the form of regular automatic backups.
HA Automation
Creating backups through HA automation is almost self-explanatory from the name. And indeed, it is a relatively simple way to avoid the need to create backups manually.
However, the method through HA automation has one major drawback, which becomes a problem over time - the created backups will remain in the directory forever, which means that you may eventually run out of disk space.
HA Automation with Auto Backup Integration
The Auto Backup integration improves the previous method by allowing you to define the number of days to keep backups on the disk - older backups will be deleted.
Before you start, you need to have HACS set up. If you don't have it yet, check out the guide.
Installing the Integration in HACS to HA
-
In HACS, go to Integrations and click Explore & Download Repositories
-
Enter
auto backup
in the search field -
Click on the found Auto Backup integration
-
In the next window, click Download twice
-
Restart Home Assistant
-
Once HA is back, go to the integration settings and click Add Integration and search for
auto backup
. -
Click through and you're done. You can now use the new services
auto_backup.backup_full
andauto_backup.backup_partial
.
Full Backup with HA Automation
For a full backup, unlike the hassio.backup_full
service, the logic for add-ons/directories is reversed. You do not define a list of add-ons/directories to include, but rather which to exclude - this list is usually smaller.
Call the service auto_backup.backup_full
.
The automation setup in the UI might look like this - backup once a week on Sunday at 22:10 keeping the last 28 days (4 weeks).
Partial Backup
Most settings are the same as for a full backup except for the list of add-ons/directories, where you specify which to include.
Call the service auto_backup.backup_partial
.
Backup Destinations
By default, all backups will be stored in the backup
directory, which will most likely be on the same disk as Home Assistant.
This is fine if you mess up something in HA and want to restore it, but it will be a problem if the disk or, heaven forbid, the entire computer fails. In that case, you will lose all backups as well.
I recommend making backups at least to a different physical disk. Ideally, to a different machine that is physically in another location.
Network Drive
HA itself allows us to define network storage, which can also serve as a backup destination.
You can find the settings in the menu Settings -> System -> Storage. Add new storage using the Add Network Storage button.
and fill in the details:
Changing the Default Backup Destination
In the menu Settings -> System -> Backups, you can select the option Change Default Backup Location from the three-dot menu (top left), and you should see all available options in the dropdown list.
Manual Backups
The quickest way to make a backup is manually. This is especially recommended after a fresh HA installation so that you have the option to revert to a fresh state if you break something.
From the User Interface
The simplest way to manually create a backup is to go to Settings -> System -> Backups and click Create Backup in the bottom right corner.
You can choose between a full or partial backup. In the latter case, you can select specific folders or, in the case of add-ons, even them.
Calling the Service
If you want to save some clicking in the UI and have it, for example, on a button, you can use the service call.
In the case of the HassOS / Supervised version of HA, it is the hassio
service.
Either call the hassio.backup_full
service for a full backup:
# Full backup
- service: hassio.backup_full
data:
compressed: true
or call the hassio.backup_partial
service for a partial backup:
# Partial backup
- service: hassio.backup_partial
data:
compressed: true
homeassistant: true # Include HA (Core part)
folders: media # all HA directories you want to back up, separated by commas
addons: esphome # all add-ons you want to back up, separated by commas
In a partial backup, you can even include only add-ons without the HA (Core)
Restores from Backup
Created backups can be used in two cases - restoring an already running HA instance or for a new installation.
Restoring an Existing HA Instance
If you go to Settings -> System -> Backups in the menu, you will get to the list of recent backups. By clicking on a specific backup, you can restore both HA and individual add-ons or directories if they are present in the backup.
Restoring a New HA Installation
After installing a new HA instance depending on the hardware and type of installation used, you should see the initialization screen with the option Restore from Backup.
Here you can provide the latest backup, and the new instance will be restored to the state in which the instance from which the backup was created was.
Comments