Objective
As the title of this post says, I want to back up my Home Assistant (HA) configs to Git, so that in case of a disaster (if I I mistakenly delete the config folder), I can recover.
Note: Disaster recovery is my 2023 personal tech resolution. But that’s besides the point.
Howto
Create an SSH key to be used for commiting your cofigs inside the HA VM.
I did this by using the ‘Terminal’ plugin within HA and running the command
ssh-keygen -f ~/.ssh/backup_key
I made mine passwordless, since from my research, having a password on the SSH key prevents automation from running the commit without a human.
I decided to create an SSH key specific for this workflow. Better to reduce the radius of disaster by sharing a key with lots of things.
TODO: figure out which files should be ignored. DB? logs? runtime files?
I hacked together a rudimentary .gitignore to not post logs, binary DB’s etc.
# Dont copy logs
*.log*
# Storage
.storage
.HA_VERSION
# No DBs
home-assistant*.db*
Once I’ve got the config directory backed up, I want to make a full HA backup as well.
ha backups new --name ha-backup-full-YYYYMMDD-HHMM
Questions
What do I have to reload to configuration to specify new shell script service?
Docs
- https://community.home-assistant.io/t/backing-up-to-gitea/369815/1
- https://www.home-assistant.io/integrations/backup/
- https://www.home-assistant.io/integrations/shell_command
- https://til.hashrocket.com/posts/uv0bjiokwk-use-jq-to-filter-objects-list-with-regex
- https://cameronnokes.com/blog/working-with-json-in-bash-using-jq/
- https://itecnote.com/tecnote/json-jq-print-key-and-value-for-each-entry-in-an-object/