Home Assistant Backup Scheduler and Monitor

Hello everyone!
I have developed a package to monitor and schedule Home Assistant backups, both in a local backup location and on a network archive.
The package is based on the supervisor, and if it can be helpful to anyone, I’m leaving the link to the repository.

https://github.com/paolo-hub/Home-Assistant-Backup-Manager

2 Likes

Did the steps but no entities are valid. Is there something i have to do with the .SH file?

pkg_backup_home_assistant.yaml i add this in my /config/package/ i not make use of this structure at all.
Have everything separate (automations, switches, sensors, etc…

also see this:

      customize: &customize
        package: "Home Assistant Backup Manager by Paolo-Hub"

    sensor.ha_backup_last_backup_date:
      <<: *customize
      friendly_name: Date
      icon: mdi:calendar-today-outline
    sensor.ha_backup_last_backup_type:
      <<: *customize
      friendly_name: Type
      icon: mdi:format-list-bulleted-type

But where are the info that has to be used in those sensors? for example?

Hi yes the sh file is for delate old backup based on the slug backup file name.
Just enable the execution
sudo chmod +x /config/backup_remove.sh
It is loaaded as

shell_command:
  # Remove old backup script
  ha_backups_remove_old: /bin/bash /config/backup_remove.sh {{ states('input_number.ha_backup_retained_number')|int(0) }}

Reguarding the vaiuous sensors about the last backup is just for info, reported in the lovelanve card.

I extract everything to add it in my config and now it’s working.

1 Like
#!/bin/bash

KEEP=$1

snaps=$(curl -sSL -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/backups | jq -c '.data.backups[] | {date,slug,name}' | sort -r)

echo "$snaps" | tail -n +$((KEEP + 1)) | while read -r backup; do
slug=$(echo "$backup" | jq -r .slug)
curl -sSL -X DELETE -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/backups/${slug}
done

I guess that I need add a token on the SUPERVISOR_TOKEN location to let this work right?

The variable is the number of retained backup, the older will be delayed.
This script is integrated in the package, in lovelance interface there is a slider to select the number of retained backup.
If you want execute it manually, invokes the scrip with the number.
You don’t need to add anything.

thanks!

Is there a reason why you have turn of the compress option?

off-topic: figured out to combine everything into 1 package as you also use. Little different but now everything combined. Will do this with more stuff to make it easier to manage.

No probem!

I haven’t added the backup compression option because typically the file size doesn’t decrease significantly. However, I could add the possibility to choose.
Regarding the unification into a single package, I didn’t include the deletion of old backups directly in the package. Instead, I implemented it in a script, which is automatically managed by the package. This decision was simply because it was much easier to implement in Bash rather than with templating.

thank you for the info.

When I do a full backup uncompressed it’s around 2.2GB and with compression 480MB so it makes for me a big difference. I have changed that to compress: true :slight_smile:

Thank you for the feedback. In this case, I can add a slider to enable/disable backup compression.

Can be helpful for other users. :slight_smile: