Searching 100% safe backup solution

Hi,
I started playing with Home Assistant about a month ago. I did several tests and learned quite a bit since then. I want to replace an old Hubitat system. But before I jump totally in it, I want to make sure I can backup and restore properly.

I am using a raspberry pi 4, with the HA OS. Brand new installation (well, a month old I guess). The important thing, I want to run everything off internet like I was doing with Hubitat.

I tried the backup feature within HA. The backup works, but the restore doesn’t. I found out that the restore requires internet to work. I’m afraid that if it requires internet it is because it’s going to get something from the internet, thus, updating something. i.e. Not being 100% restoring like the backup was made. There will be chances that something that WAS working fail to work because of that difference. To me, this is unacceptable.

So I decided to try a complete image of the sd card. So I exited from HA and waited for HA to terminate all its jobs and shutdown properly. then I used another computer (ubuntu) to make a disk image of that SD card. I used a same size SD card and restore that image onto it. Then tried to reboot the raspberry pi with this new SD card but it failed to start. After hooking a monitor to this pi, I saw that it waited for the home Assistant CLI to be ready, and then failed and jumped into emergency console.

I found on the internet that some people taped LOGIN and then it restarted properly. I tried and it worked once only.

That is the first time I’ve seen a disk image not acting like the original. I tried to redo the image again and retest it, but exactly same behaviour.

Until I find a proper way to restore HA, I can’t use it. I’m really sad, cause I loved what I saw in HA so far. So 3 things;

  1. How to use the HA restore feature without internet?
  2. How to make a disk image of HA that will work?
  3. Any other suggestion to have a 100% restore that would work without going through a full install and restoring backup?

The RPi4 needs an internet connection to access an NTP server to set the time on the RPi4 because the Pi does not have a battery backed up clock onboard. I have seen other discussions on this forum for getting around this but I have not tried them - I am ok having an internet connection (I manage my internet traffic using firewall rules). Home Assistant also needs an internet connection to check HA component updates but you decide if / when to apply these updates.

My procedure:

  1. Shutdown Home Assistant: Settings → System then click the “power” button in the upper right corner
    image

  2. Power off the RPi4 before removing the SD card.

  3. Remove SD card and mount on a Windows 10 PC (I have not upgraded to 11 yet).

  4. Shutdown / exit Google Drive (this is an important step for me because the next step will not work if I do not do this).

  5. Run Win32DiskImager to Read the contents from the SD card to a windows image. Note: you need enough free disk space to handle the entire size of the SD card regardless of how much space is actually used on the SD card).

  6. Get another identically sized SD card and format it using SD Card Formatter.

  7. Run Win32DiskImager to Write the windows image file back to the SD card.

  8. Use the Windows Eject (safely remove) the SD card from Windows.

  9. Place the new SD card into the RPi and reapply the power.

I have been using this procedure every month for over 4 years. It has never failed. It proves that the backup AND restore actually work. Since the old SD card is a working system, you know you can drop back to it if needed (which I have done a few times for various reasons).

I have a set of 4 SD cards that I rotate through: Current (production), backup 1, backup 2, backup 3. I have never had an SD card failure…yet. But if I do, I’m ready. The down side of this approach is that I could lose up to a months worth of historical data. That does not matter to me but it might to others.

I also use the Google Drive add-on solution. This runs on a weekly schedule but I have never needed to restore using these backups (I really should test this :slightly_smiling_face:).

You may also want to look at: Disaster Recovery Planning. It is part of the Home Assistant Cookbook Index that has some other good info too.

Thank you for responding. Very nice!
For the NTP, it’s not a problem here. I have one of the pi with a battery backup RTC. He is the one that sends the time on the network to all other PIs and computers. I had to do that for the Hubitat at the beginning.

I have found my problem with the disk image. I wasn’t aware that 2 SD cards with both 32 gig could be different in real size. Yes that’s true. When I restored on the card with the Ubuntu DISK utility, it flashed a warning that the size was smaller. I didn’t pay attention to this message and it restored anyway. But obviously, not correctly. Found another SD card 32 gig too small again, but finally found one (different brand) that was big enough. I’ll watch the message better next time :wink:

Your idea about the rotation 4 SD cards is what I’m going to do too I guess. Now that I can image it properly :wink: The google drive is out of the question as it would require internet. But I do have my own cloud on that network. I’ll see what I can do with that to preserve the history.

Thanks for the link about the Disaster Recovery planning.

1 Like

The DR link has a solution (samba) that I think will work.

1 Like

Before going further on the backup thing, then wait for the next release of HA core.
It should arrive today and the backup features have been given much love after the last release extreme make over.

Ho Super. Thanks