jcwillox / hass-auto-backup

🗃️ Improved Backup Service for Home Assistant that can Automatically Remove Backups and Supports Generational Backup Schemes.
https://jcwillox.github.io/hass-auto-backup
MIT License
368 stars 27 forks source link

If additional download_path isnt available, Backups get not created / event backup_failed not fired #88

Closed dafunkydan closed 1 year ago

dafunkydan commented 1 year ago

The problem

If download_path: isn't available, even a regular local Backup doesn't get created. Worse, in that Case auto_backup.backup_failed isn't triggered.

Only in the Trace of the Automation the Error gets logged: Stopped because an error was encountered at February 10, 2023 at 09:00:00 (runtime: 0.03 seconds) not a directory @ data['download_path'][0]

I would expect, that even if there is a Problem with the download_path (for whatever, unintended, Reason) at least the Local Backup still gets created. Additionally, a backup_failed - Event would help to become aware of that Situation.

What version of Auto Backup has the issue?

1.3.0

What version of Home Assistant are you running?

Home Assistant 2023.1.7

What type of installation are you running?

Home Assistant OS

If you're running HA OS/Supervised, what version of the Supervisor are you running?

Supervisor 2023.01.1

Example YAML snippet

service: auto_backup.backup_partial
data:
  name: AutoBackup {{ now().strftime('%Y-%m-%d %H-%M') }} Partially
  addons:
    - Adguard Home
    - core_mosquitto
    - core_samba
    - Studio Code Server
    - core_ssh
    - deCONZ
  folders:
    - homeassistant
    - share
    - ssl
    - Local add-ons
  keep_days: 2
  download_path: /media/fritznas_backup

alias: General - Backup Failure Notification
trigger:
  - platform: event
    event_type: auto_backup.backup_failed
action:
  - service: persistent_notification.create
    data:
      title: Backup Failed!
      message: >-
        Name: {{ trigger.event.data.name }} // Error: {{
        trigger.event.data.error }}

Anything in the logs that might be useful for us?

Stopped because an error was encountered at February 10, 2023 at 09:00:00 (runtime: 0.03 seconds)
not a directory @ data['download_path'][0]

Additional information

No response

jcwillox commented 1 year ago

This is intensional, the service call doesn't pass validation, so it doesn't even start the backup process. The service schema ensures that download_path is a directory. I suppose it could be useful to still trigger the backup_failed event but I don't think that's possible as HA handles the validation rejection. Perhaps you could make your script handle the error itself using something like https://www.home-assistant.io/docs/scripts/#continuing-on-error.