Backup Your Home Assistant Config to Git


I run my Home Assistant of a raspberry pi using Docker. I found this to be a great way to run multiple different containers as well as Home Assistant. If you are like me, and like to tinker with the YAML files, you can very quickly end up overwriting working config with something that’s not working at all. I’ve learned my lesson by not having a backup of the files.

I’ve had a look at multiple ways to backup your configuration files, using SSH, using SCP, File shares etc. but I believe using GIT with version control is still the safest .

I’m not going to recreate a post around how to setup git on the PI or how to commit files into a GIT Repro, but you can follow the example from It is very straight forward.

After you’ve completed the setup of GIT on your host running your docker, you can add your required YAML files by using the following commands.

sudo git add configuration.yaml
sudo git add automations
sudo git add groups.yaml
sudo git add secrets.yaml
sudo git add scripts.yaml

This will add your files into the local repro, now you have to push it to GitHub

sudo git commit -am "First Commit"
sudo git remote add origin
sudo git push -u origin master

and there you have it, the next step for me is to create a script to run all the commands and push a backup to my GitHub repro before I made changes.