Add automatic backup event entity (#39151)

This commit is contained in:
Michael 2025-05-23 17:02:17 +02:00 committed by GitHub
parent 68aee9ce90
commit 62b307da6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@
title: Backup
description: Allow creating backups of container and core installations.
ha_category:
- Event
- Other
- Sensor
ha_release: 2022.4
@ -12,6 +13,7 @@ ha_codeowners:
ha_iot_class: Calculated
ha_platforms:
- diagnostics
- event
- sensor
ha_integration_type: service
related:
@ -76,6 +78,8 @@ action: backup.create
This is a YAML example for an automation that initiate a backup every night
at 3 AM:
{% raw %}
```yaml
automation:
- alias: "Backup Home Assistant every night at 3 AM"
@ -87,10 +91,49 @@ automation:
action: backup.create
```
{% endraw %}
## Restoring a backup
To restore a backup, follow the steps described in [Restoring a backup](/common-tasks/general/#restoring-a-backup).
## Event entity
The **Backup** {% term integration %} provides an {% term "Event entity" %} which represents the state of the last automatic backup (_completed, in progress, failed_). It also provides several event attributes which can be used in automations.
| Attribute | Description |
| --- | --- |
| `event_type` | The translated state of the last automatic backup task (_possible states: completed, in progress, failed_)
| `backup_stage` | The current automatic backup stage (_is `None` when `event_type` is not in progress_) |
| `failed_reason` | The reason for a failed automatic backup (_is `None` when `event_type` is completed or in progress_) |
### Usage examples
Send notification to mobile app, when an automatic backup failed.
{% raw %}
```yaml
alias: Backup failed
triggers:
- trigger: state
entity_id:
- event.backup_automatic_backup
conditions:
- condition: state
entity_id: event.backup_automatic_backup
attribute: event_type
state: failed
actions:
- data:
title: Automatic backup failed
message: The last automatic backup failed due to {{ state_attr('event.backup_automatic_backup', 'failed_reason') }}
action: notify.mobile-app
mode: single
```
{% endraw %}
## Sensors
The **Backup** {% term integration %} provides several sensors.