Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
Or you can import this Blueprint by using the forum topic URL:
blueprint:
name: Automated Daily Snapshot
description: Create a full snapshot backup at a given time every day.
domain: automation
input:
trigger_time:
name: Snapshot creation time
description: The snapshot will be created at this time, every day
selector:
time:
send_notification:
name: Send notification
description: Sends a notification to a device if enabled
selector:
boolean:
default: false
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications
selector:
device:
integration: mobile_app
default: ""
mode: single
max_exceeded: silent
variables:
backup_filename: "Automated backup {{ now().strftime('%F') }}"
send_notification: !input send_notification
notify_device: !input notify_device
notification_title: Automated Daily Backup
notification_message: "Home Assistant full backup created. {{ now().strftime('%F') }}"
trigger:
- platform: time
at: !input trigger_time
action:
- service: hassio.snapshot_full
data:
name: "{{ backup_filename }}"
- choose:
- conditions: "{{ send_notification }}"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
title: "{{ notification_title }}"
message: "{{ notification_message }}"
This is only half the task. You need to get those backups off the home assistant server in case of storage corruption. For which these addons are a better option:
I copied and modified this blueprint to take zfs snapshots on my TrueNAS server. Details are OT but this simple blueprint combined with a rest_command allows me to easily reproduce the same automation on different datasets. It’s very simple and that’s why I like it.
I can see simple blueprints being attractive to new users who don’t want to yaml
Hi, would it be possible to make a blueprint where you could select the frequency and partial items of teh snapshot. instead of full and daily. Like weekly and partial with selection of the partial items.
Frequency: With the current selectors (input types) it is possible to do with toggles for every day (like in the Time condition on the Automations UI). I hope we will have a built-in selector for this in the future, so this would be easier.
Partial snapshot: there is the hassio.snapshot_partial service, but you have to define the parameters with optional lists which seems complicated.
I think it can be done with Folder watcher and something like an input_boolean, which turns on if there was a change in the config during the day and resets every day.
Yep, didn’t realize that integration is recursive. You don’t need an input boolean, just use a trigger based on the modified event and created event.
Nice idea! One gotcha though, if you are going to watch the full /config folder with folder watcher make sure events for modifications to the db file and log are excluded.
The DB is the biggest problem since it updates so much. For anyone that uses the MariaDB add-on this isn’t an issue but if using the out of the box configuration the entire DB is a file in /config. I made this mistake once and almost fried my CPU before I realized what had happened. Made me very glad I had set up alerts for the CPU temperature rising too high.
Sadly that’ll make it a bit tricky to implement in practice since you can only provide inclusion patterns to folder watcher. There’s a lot of random subfolders created by integrations and things and it doesn’t help that many of the files (including all the ones in .storage) have no extension so its tough to make an inclusion filter for them.
Really need an “exclude this file/pattern” option.
Sound good. For the schedule I will try to use the scheduler card to turn on and off the automation. For the partial backup that was more a nice to have.
Can a database stop be added so the database is stopped prior to the snapshot and restarted after it completes? I just found out that the add on snapshot to google drive allows the db to be stopped prior to the backup. This is needed to prevent a db corruption. I just did a snapshot and restore to a new device and this works. Also the add-on can be schedule so I’m not sure the need of this blueprint.
thank you so much for this really helpful blueprint!
I’m kickstarting a small project which aims to create a curated collection of reliable, documented and high quality blueprints, which could eventually become a valuable resource both for Home Assistant newcomers and experienced users.
I published Awesome HA Blueprints as a website which can be easily browsed, but the codebase, including the list of blueprints, is available in this GitHub repository . The project is still in its early stages but I hope many blueprints will be added in the upcoming weeks and months.
Here’s the original thread:
It would be amazing to have this blueprint in the collection.
If you’ve time and you’re interested in contributing and helping the project, it would be great if you could submit your blueprint by opening a Pull Request there. Also, I could take care of adding it to the list if you’d like to.
Just let me know.