Integrations

Backup

Spook adds actions that list, delete and clean up the backups of Home Assistant, and make a manual backup from an automation.

The backup integration makes the backups of Home Assistant. Its settings make an automatic backup on a schedule, and delete the oldest automatic backups beyond the number or the age you keep.

Only the automatic ones, though. A backup you made by hand, or one Home Assistant made before an update, stays until you delete it on the backup page. One at a time. Those pile up, and eat your disk or your cloud storage. And an automation can make a backup, but not with your choice of what goes in it, and it cannot list or delete one at all.

Spook adds four actions for that: list the backups, delete them, clean them up by a rule, and make a manual backup with what you want in it.

Actions

Spook adds four actions to the backup integration. You find them wherever you add an action, marked with a 👻. All four are for administrators only: a backup holds everything of your home, and is what brings it back.

List backups

Lists every backup, the newest first, as the backup page shows them: its name and date, where it is stored, whether it is encrypted, whether it was made automatically, and what it holds.

How to use it

  1. Open the automation or script that needs the list, and select Add action.
  2. Search for backups, and select Backup: List backups 👻.
  3. Under Response variable, give the list a name, like backups. The steps after this one can use it.
  4. Select Save.

Just want to see your backups? Try this action opens it in your Home Assistant, ready to run once. The list shows up below the action.

Delete backups

Deletes one or more backups, from every location they are stored in. The same as the delete on the backup page, for as many backups as you like.

A backup that does not exist is skipped, not an error. Ask for the response to see which backups were deleted, and which were not found.

When a location cannot delete a backup, for example because the cloud is out of reach, the action still deletes everything else. Then it fails with an error that names each backup it could not delete, and where.

Before each backup it deletes, the action checks that no backup is being made or restored: a restore reads the backup it restores. When one has started, the action stops, and the error says which backups it already deleted, and which a location could not delete.

How to use it

  1. Open the automation or script that should delete backups, and select Add action.
  2. Search for backups, and select Backup: Delete backups 👻.
  3. Under Backup ID, enter the IDs of the backups to delete. Backup: List backups 👻 gives them.
  4. Select Save.

Purge backups

Deletes backups by a rule. Keep a number of the newest, delete the ones older than a while, or both. Unlike the backup settings of Home Assistant, it deletes the backups you made by hand too.

  • Keep keeps that many of the newest backups, however old they are.
  • Older than deletes only the backups older than that, but never the newest one.
  • With both, a backup is deleted only when it is not one of the newest to keep and older than that. Keep 3 and older than 30 days always leaves the newest three, and keeps every backup younger than 30 days on top.

One of the two is needed. Without either, the action refuses.

Purge always keeps the newest backup it looks at. Without Keep, it keeps that one as if you said keep 1. A backup schedule that broke weeks ago makes every backup old, and an age rule alone would then delete the last backup you have. This one stays.

Automatic backups chooses which backups the rule looks at. Leave it out for all of them. Turn it on for only the backups the automatic backup settings made. Turn it off for only the ones made otherwise, like by hand or before an update. A backup made by another installation, or before Home Assistant kept track, is neither: Home Assistant does not know how it was made. Those are only purged with Automatic backups left out. Keep counts among the backups the rule looks at: keep 2 with automatic backups off keeps the two newest backups the automatic settings did not make, by hand or before an update, whatever the automatic ones are.

A backup with a date that cannot be read is never deleted by age: nobody knows how old it is. For keep, it counts as the oldest.

Try a rule with Dry run first. It decides what to delete, deletes nothing, and the response says what it would have deleted.

The action does not purge when it cannot see every backup:

  • When a location could not be asked for its backups, like the cloud being out of reach. A backup stored only there would be missing when counting the newest, and the newest you have could be deleted. The error names the locations.
  • While a backup is being made or restored, also when one starts while the action lists, or between two deletes. Try again once it is done. When it stops halfway, the error says which backups it already deleted, and which a location could not delete.

How to use it

  1. Open the automation or script that should clean up, and select Add action.
  2. Search for purge, and select Backup: Purge backups 👻.
  3. Fill in Keep, Older than, or both.
  4. Select Save.

Create manual backup

Makes a backup with what you choose in it and where it goes. The backup page calls that a manual backup: the backup settings never delete it, so it stays until you delete it, or purge it.

The action waits until the backup is done, as the backup action of Home Assistant itself does. Ask for the response to get the ID and name of the new backup.

Without Locations, the backup goes where your automatic backups go. Without automatic backups set up, it goes to this machine, as backup.create of Home Assistant does. On Home Assistant Operating System, that is the Supervisor's location on this machine. A location that is not available right now is skipped, as long as one of them is.

The backup is encrypted with the encryption key of your automatic backup settings, the same key the backup page uses for a manual backup. Home Assistant makes that key when you set up automatic backups. Before that, there is no key, and with Encrypted left out the backup is made without encryption. Without automatic backups it goes to this machine only, so nothing unencrypted leaves it unless you give Locations. Turn Encrypted on to refuse a backup without encryption, or off for a backup that is never encrypted. A location you set to keep its backups unencrypted, in the backup settings, still gets its copy unencrypted.

Apps and folders only go in a backup on a Home Assistant with a Supervisor, like Home Assistant Operating System. Elsewhere, the action refuses them.

Only one backup at a time: while one is being made or restored, the action refuses.

How to use it

  1. Open the automation or script that should make the backup, and select Add action.
  2. Search for backup, and select Backup: Create manual backup 👻.
  3. Choose what goes in it, and where it goes.
  4. Select Save.

Missing something here?

An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.