Moving configuration from bad disk to good one

I’ve had HA on a Pi4. I installed HAOS on a USB thumb drive. (Since I’ve had problems with SDCards getting easily corrupted, I prefer putting the OS for a Pi on a thumb drive.) We’ve had some network issues lately, with several storms, and a number of changes. I came home the other evening to find HA had not turned on lights it usually turns on. I tried to access it by my phone and then from a wired connection via the web interface. It wasn’t there. I checked the DHCP leases on my pfSense box (which does firewall/dhcp/dns work for my LAN) and the HA system was not visible on the LAN.

I hooked up m monitor and a keyboard to the Pi and rebooted it. I can see the text at the very start of the boot sequence, but after that, the screen goes black. (Apparently there’s a video signal, but it’s blank or black.) I pulled my HA system, on the USB stick, out and put it in another Pi4. I got the same result: When booting, after the initial info showing up, the monitor stayed black.

So I have a bad partition or something else and it’s not fully booting. Also, when I tried reading the HAOS system from another Pi,

I can access /hassos-overlay, /hassos/data, /hassos/kernel, and /hassos/kernel1. There are several partitions that were not identified that I could not see. With where I have this on my system, they are sdb1, sdb3, sdb5, and sdb6. I don’t know if those should be readable or not.

I’m downloading a new HAOS image and putting it on a USB drive. I want to be sure I get my full configuration, including scripts, macros, scenes - everything - transferred to the new drive.

I have found this page, but that’s a lot of directories within /hassos/data. What’s the best way to copy over what I need to duplicate my previous system on the new USB drive? Should I just use rsync on the entire /hassos/data partition to sync the new system with my previous one? Or should I focus on specific directories?

(Also, I went into the background of this in case it makes a difference - so if anyone has a simple fix to make the system boot, without me having to copy things over, please let me know.)

As far as I have understood, thumb drives and SD cards are very similar in lifetime since they are essentially the same thing.

Don’t you have a proper backup?

Maybe so, but my experience is that when we’ve had power outages or flickers, EVERY SDCard based Pi system I have has needed to be reconfigured, while the USB based ones haven’t needed that. It could be the brands I’ve used or random chance, but I’m sticking with what works. As for this case - I’m not sure, and probably never will be, if this failure is due to the media or other issues. Maybe a partition got garbled when there was a power flicker and the system tried to restart with each flicker.

Backup RAID had problems, too. While it looks like my main data backups are going to be okay (still not sure about one of them), my tablet backups and a few configuration backups (like this, my DVR, and my firewall backup) seem to be hosed. (At least the firewall was still working so I could just back up the config somewhere else.)

I have an answer - got it from experimentation.

I plugged in my failed HA system (on a USB drive) to a Linux computer and I created a new HA install and plugged that in (also on a USB drive) as well. When I plugged in these devices, my Linux system wanted to mount several partitions on the HA setup. One was /hassos-data. The other partitions I could mount aren’t an issue. When I plugged in the new, not yet setup HA install, I also had /hassos-data1.

The files that matter are in /hassos-data/supervisor. Since this was on a Raspberry Pi 4, running Raspbian, the full path to the two directories are /media/pi/hassos-data/supervisor and /media/pi/hassos-data1/supervisor. Your system may differ in the directory locations and you may get another name for the 2nd one (the new HA install) other than /hassos-data1.

To copy the files I ran:

sudo rsync -av /media/pi/hassos-data/supervisor/* /media/pi/hassos-data1/supervsor

It didn’t take long for all the files to be synced. Once I did that, I shutdown that Pi, then put the USB stick with my new Home Assistant setup back in my Pi for Home Assistant and booted it. My configuration was in there and worked.

I want to add one note to this: I don’t know why, but even with a lot of Google searching, looking at forums, and asking here, nobody seems to have documented this point and I think it’s a critical one to pay attention to. I’m sure I’m not the only person who has had to rescue data off a non-working Home Assistant install. Even for those of us who keep backups (which I do), things can go wrong. In one storm, I lost Starlink internet, my Home Assistant install, and my backup RAID went down. (It looks like only my directory with config backups for smaller systems got hosed, but I’m still waiting for that to reconstruct everything it can. It may be possible, when all is done, that my config data might survive - but I didn’t want to wait for that to get my system back up.)

So if you have to restore your Home Assistant system, get the data from /hassos/supervisor - recursively copy all of it in that directory.