Home Assistant Backup¶
Creates on-host and off-host snapshots of Home Assistant configuration, data, logs, Traefik/systemd definitions, and produces a manifest for integrity checks.
Highlights¶
Validates required paths before running.
Uses
sqlite3 ".backup"to capture a consistenthome-assistant_v2.dbwithout stopping the service.Rsyncs
config/,data/,logs/(optional) to/opt/backups/homeassistant/<prefix>-<timestamp>/.Captures Thread + Matter state (
/var/lib/threadand any Matter Server storage/chip factory dirs outsidedata/).Copies rendered Traefik file and systemd unit, then writes
metadata.yml+manifest.sha256.Optionally creates a
tar.gzarchive and fetches it to the control machine (~/backups/homeassistant/by default).
Key Variables¶
homeassistant_backup_prefix– naming convention (e.g.manual,pre-deploy).homeassistant_backup_include_logs– include/exclude logs.homeassistant_backup_create_archive/homeassistant_backup_fetch_local– enable tarball generation + download.homeassistant_backup_sqlite_path/homeassistant_backup_use_sqlite_backup– database snapshot behaviour.homeassistant_backup_extra_dirs– additional directories to include in the snapshot.
Usage example:
- hosts: homelab
become: true
roles:
- role: local.ops_library.homeassistant_backup
vars:
homeassistant_backup_prefix: nightly
homeassistant_backup_include_logs: false