Skip to content

Advanced Examples#

Generational Backups#


Create backups each day and keep them for a configurable amount of time, backups are stored less frequently the older they are.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.


Generational backups allow you to store backups over a long period of time while still having frequent enough backups to be useful for recovery. This is done by reducing the frequency of backups as they get older.

Personally I take a backup of the Home Assistant configuration every 3 hours for the first 2 days, then full backups each day for a week, and finally each week for a month.

For example, lets say my database has corrupted and I want to restore it.

If it has been less than 48 hours since it corrupted then I can restore to the exact point before it corrupted with an inaccuracy of at most 3 hours (if you're monitoring trends you don't want to lose hours worth of data, so an average accuracy of 1.5 is pretty good),

If 48 hours have passed then I can restore to any point with a maximum inaccuracy of 1 day (average accuracy of 12 hours) over the past 7 days (excluding the two where the db was corrupted).

Over a week I can restore to any point ±1 week over the past 3 weeks, while ±1 week isn't very useful for restoring a database, it can be useful for subtle thing you don't notice, like if you accidentally deleted something.

This is substantially more efficient than storing a backup every 3 hours for a month, and while you lose some accuracy as the backups get older, most failures (if they even occur) will be noticed within 48 hours,

Also, most things other than your database don't change that often so a 4-week-old backup of your home assistant config may be the same as 1 day old backup. Also in my case the 3 hourly backup only backs up the important files to save on storage, whereas my daily/weekly backups are full backups.

Of course, you can tweak these values to your liking, or even add a month/yearly backup schedule 👍.


Partial backup every 3 hours
- alias: "AutoBackup: Hourly Backup"
  trigger: # (1)
    platform: time_pattern
    hours: "/3"
    # partial backup to save storage
    service: auto_backup.backup_partial 
      name: "AutoBackup: {{ now().strftime('%a, %-I:%M %p (%d/%m/%Y)') }}"
        - core_mariadb
        - core_mosquitto
        - homeassistant
        - share
        - ssl
      keep_days: 2
  1. Automation triggers on every 3rd hour.
Full backup every day except Mondays
- alias: "AutoBackup: Daily Backup"
    platform: time
    at: "02:30:00"
    condition: time
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
    service: auto_backup.backup_full
      name: "DailyBackup: {{ now().strftime('%A, %B %-d, %Y') }}"
      keep_days: 7
Full backup every Monday
- alias: "AutoBackup: Weekly Backup"
    platform: time
    at: "02:30:00"
    condition: time
      - mon
    service: auto_backup.backup_full
      name: "WeeklyBackup: {{ now().strftime('%A, %B %-d, %Y') }}"
      # store backup for a month
      # i.e. backup each week and store for 4 weeks
      keep_days: 28