Is there an easy way to backup/restore

Hi All,

I wanted to find out if there is a better way of being prepared to SD card failure than I have.

Currently I manually diff/copy files between my @ RPi3B and a Github repository’s copy on my Mac (via Samba). The Samba add-on does’t work well: often it reports things like ‘no such file or directory’ after creating new ones on the SD card so I have to unmount/remount it, but that’s another story.

So I have a backup of my /config folder, but it does not automatically include .storage folder’s content and I have to copy lovelace file individually (I use Lovelace in UI mode, not yaml) - a bit of a pain.

My system relies on input_xxx, automation etc being able to restore their state after HA restart, i.e I don’t use initial and don’t need to worry about storing their states.

However, when an SD card fails and I need to restore my system, there is no way to get these states back, is it? So apart from all that files I need to keep these states and it sounds crazy.
Yes, I can go through all of them and set them appropriately, but it a) takes time b) doesn’t always work as I don’t remember any single setting because there ar so many of them.

So it sounds and it really is a bit complicated for a good backup solution, isn’t it?
Any thought if it’s possible to improve something in this department?

Hassio has a snapshot function, it backs up your entire config, the add-ons and everything else needed to fully restore an instance. If you have a failure, you re-install hassio, load the snapshot on to the new instance, and click restore. Wait 10-15 minutes and your instance is brought back just as it was. (the database is usually wonky as its missing a chunk of time but delete that file and it runs again no issues, you just lose some history)

If your running hassio, snapshots are you best backup option. There are addons to automatically backup and send it to a dropbox/google drive type service or you can search around for other options to get a second copy somewhere safe via other means.

1 Like

Backups aside, on the rPi3B+, I’d recommend getting a USB thumb drive (or better, an actual external drive) and using that instead of SD cards. You can boot up off of it and save a lot of money by not having to buy SD cards when they die.

Beyond that, use the snapshot add-on.

This is what I use.


I just moved Hassio from RaspBerry to Hyper-V

  • Installed Samba on Hassio
  • Took full snapshot
  • Copied snapshot from raspberry samba\backups
  • Set up Hassio on new HypeV machine
  • Installed Samba
  • Copied snapshot to hyper-v samba\backups
  • Rebooted Hassio
  • Wipe and Restored snapshot

And everything back to normal :wink:

If you are reluctant to change the way your hassio is configured as recommended by @code-in-progress ?
Then I would suggest imaging your SD card after any significant change. You can then use the snapshot to backup minor changes. While I do not use a pi for hassio I still do images of my drive. In this way should it fail then I can be up and running quickly too.

I posted about this a while ago here;

It does offer some insight how others handle this topic.
For the minimal downtime an image will create will easily be offset by the hours of configuration time.

1 Like

Thanks for mentioning the snapshot feature. I tried to use it long time ago and it didn’t work for me as HA refused to restore from a snapshot after an update.
At that point I did my research and went for SD card imaging, which I carried on for a long time but eventually stopped because it involved shutting HA down, taking out SD card, inserting in into PC and waiting for about 30 minutes (for 32GB card) for the process to complete (and then compressing the image).
I think I stopped doing that because it works well if you restore to the very same card. It will most likely complain about different media size if you try restoring to another card despite it being of the same nominal size (say, 32 GB).

I’m reluctant to replace SD card with a USB thumb drive/SSD as it only eliminates one of the weaknesses and I’d rather go barebone/Linux laptop way to improve reliability and responsiveness of HA setup.

The trouble with snapshots is it’s only readable by HA so it’s impossible to look inside and check that particular option/automation, one need to restore the whole thing…

You should be able to open them with archive manager in a linux desktop. that will allow you to extract a file to restore. They are after all .tar files!
If you are a Windows user then try 7-zip.

Also a good practice is to run snapshot both before and after any update.

95% of the work in any setup is the config. If all you do is copy your configuration.yaml, ui-lovelace.yaml and ‘other’ yaml files then you’ve saved yourself days of work.

As far as I’m aware the snapshots are now pretty version insensitive but there maybe breaking change issues.

I would be concerned about “samba being flakey” that implies a much greater problem as this sort of software is not picky about how you hold your tongue. Maybe a dodgy cat 5 (or 6) cable or a dirty connection in a port ?

yeah, I was happy to know that my config is backed up and ready to restore BUT I was really annoyed when I realised I need to go and change all those input_numbers for things to work as expected.It’s especially important as nowadays we can enable/disable automations from UI - on a new system all automations are on by default…

that is exactly what stops me from going that way (maybe I’ll combine it with my current approach?)

agree, but don’t know how exactly to tackle it. doesn’t happen when I connect to Windows shares.
will try to replace the cable (almost 100% sure I did it in the past). apart from that no dirt, nothing suspicious… :() It’s very annoying, but at least it does not corrupt my files :wink:

Another option…

You can download snapshots to a PC. Just click on the snapshot and there’s a down arrow at the bottom of the pop-up card. The file will be in the download directory associated with your browser, and you can move it to a directory on your PC file system. Alternately, you can use the Configurator add-on to download a snapshot, since it’s also needed for uploading it back to HA.

If you’re using the Configurator add-on, you need to get access to the ‘/backup’ directory where snapshots are stored. It’s at the root level above the ‘/config’ directory, so you should have the following line in the add-on configuration:

"enforce_basepath": false,

From there, you can upload and download snapshots.

Thanks, it really works!

Is it? I always use SAMBA, haven’t heard about this add-on… perhaps because I tend to edit my config on PC/in place through SAMBA manually.

Thanks for the hint anyway!

A while back, Configurator was a recommended add-on during a basic installation of Hass.IO. I see it now appears under Advanced Configuration:

Can anyone confirm if you can restore a backup from an older version of HASS onto a newer version? Breaking changes aside, would this work?

This does work.

You can choose, it is a full backup, including home-assistant (version xxx) as well as configuration, SSL, Share, Media and Local add-ons.
You can choose which of those you want to backup/restore :wink:

where can I find my lovelace config in shapshot.tar ? I have an issue that the latest snapshot is not recognized by home assistant, so I restored previous one. But there was really a lot of work in UI after that, so I would like to restore also lovelace config.

Assuming you are using the UI for config and not YAML (else you would know where to look) take a look at the storage directory.

Tread lightly in this directory, backup first, and be sure to stop HA, make your changes and then restart.

For those who are interested. I backup my ha with a full snapshot automatically. The issue is that it stays on your SD or SSD which if it crashes your snapshot crashes with it (personal experience :confounded:).

On a Mac you can install Automator which is an app to automated routine task on your Mac. I have configurated an small sequence which basically downloads the latest snapshot from my SSD card and stores it safely on my Mac. To restore in case of total loss you need to reinstall HA and upload the snapshot into the backup folder but that is easy and works smoothly. No longer sleepless nights!

There are also easier solutions:
One is automatic backup to a Samba share:

and one is automatic backup to Google-drive (to have it really outside the house):