Just wanted to share a Home Assistant add-on with you which allows you to create snapshots and store them on a Samba share. You can check it out here: Samba Backup
There are already similar add-ons available which upload snapshots to Dropbox or Google Drive, but I did not find anything that directly copies to a local NAS. So I created this one.
Main Features:
Automatically create snapshots (full or partial) and copy them to a Samba share
Cleanup specified number of snapshots locally on the device and on the share
Time-based schedules are supported out of the box, advanced triggers can be implemented with a Home Assistant automation
A sensor for Home Assistant informs you about status changes and provides you with some statistics
I appreciate any kind of feedback, suggestions or improvements are welcome!
If you like this add-on, please the Github repo. Thanks.
Nice! This would considerably simplify my off server backup. Iām currently relying on a file sync service running on an always on windows PC to sync backups between Home Assistant and a NAS. And using another custom component to delete old backups.
The only thing holding me back is that your addon only seems to do full backups.
Iāve found I need to exclude some addons to keep the backup small enough to complete in a reasonable time.
Is it possible to do partial snapshots?
Or being able to call the copy and cleanup without creating a backup (I can do the partial snapshot with an automation beforehand).
Yes youāre right. Currently only full backups are possible.
But partial backups can definitely be implemented since they are supported by the Home Assistant CLI which I use to create the snapshots. Iāll see what I can do.
Already thought about that, but Iām not completely sure yet how a solution should look like.
Maybe it would be a good idea to support a daily backup out of the box. And for everything else one has to create a separate HA automation as this gives way more flexibility when to trigger a backup.
Just an idea (Iām happy with the flexibility of using an automation), you could add a simple schedule to the configuration, e.g. last two options here:
Would be a possibility. Iāll probably take a look at that soon.
Meanwhile I released version 1.4 which now supports partial snapshots!
You can specify add-ons and/or folders to be excluded. For the add-ons you have to provide the slugs. In a future release Iāll try to improve that, so that you can also configure it via names instead of the slugs.
Unfortunately, I had to change the role to manager in order to be able to access the installed add-ons. This now results in a bit less security rating.
Every Home Assistant add-on has a unique name which they called for whatever reason slug. To my knowledge the slug is somehow created from a hash of the repository name, apart from the official ones. They all start with ācoreā, e.g. core_ssh.
You can easily find out the slugs by clicking on an installed add-on. The slug is part of the URL.
Thanks. I have the list of slugs already then. As I was using them (without knowing what to call them) in my automation linked above. Actually, looking closer, I have the list of ones I include, but finding the ones I want to exclude will be just as easy now.
This looks very good.
I donāt want to introduce feature creep where itās not wanted but would you consider an option to copy (some or all of) the config folder as plain files?
My backup routine currently consists of an automation to do a snapshot and then every day when I turn on my Windows PC a scheduled job runs to copy the snapshot to my OneDrive folder along with a plain copy of my config folder. (It also does some housekeeping to delete old snapshots etc but thatās not relevant here).
I canāt tell you how often I have gone to those plain files to quickly restore single .yaml file after an āimprovementā turned out not to be so!
No big deal if that is outside the scope of what you want to include, I can continue as I am now, but I thought Iād ask.
Just one thing, there were 20 existing snapshots in my backup folders when the samba backup automation ran. Now there are 21. Even though I have keep 20 set for local and remote.
I take it this is because samba backup will only delete itās own automated backups?
There is one thing Iād love to see in your addon, customizable snaphot name patterns.
Up to now I used the Google Drive Backup addon which allowed to generate names containing the HA version number. Here is s screenshot:
Itās the intended behavior to only delete snapshots that were created with this add-on. I search for all snapshots that include āAutomatic Backupā in its name, which makes it a bit hard to make the name customizable.
Regarding plain files, I would rather say not planned at the moment. I donāt really think itās a good idea to blow up the configuration possibilities and it would probably complicate the cleanup routines.
What is really the benefit of having plain files? The homeassistant folder, which contains all config yaml files, is included in every snapshot by default. So you just have to extract the tar file in order to get to the plain config files.
Yes but it is several levels down. Not a big deal but it is just very convenient to have them at hand for those times when you make a complete mess of something you were trying to improve!
I just released version 2.0 of Samba Backup. This is a breaking release, so please read the following before updating.
All snapshots stored on the device will now be cleaned up.
Custom names including name patterns {type}, {version} and {date} are now supported. These patterns will automatically be converted to its real values.
Out of the box triggers are now supported. If you need an advanced trigger, you can still use a separate Home Assistant automation. But be careful, your existing automations will not work anymore as the syntax has to be different now.
Samba Backup is now started as a service running in the background.
All details can be found in the README. If you like this add-on, please give it a star in Github. Thank you
Should be possible, but I donāt know how much effort this means.
We could probably use the mqtt service to publish the current state (Backup started, Backup finished sucessfully, etc.) on a predefined topic. Then you could hook up a mqtt sensor to receive the messages and do whatever you want.