Bricked SD card after power outage

Hello, new on these forums, came here due to an issue I recently experienced and would like some advice.

I have had HA running on an RPi 5 for at least a year. Yesterday I had a 5 second power outage which, for some reason, bricked my SD card. When I power on the RPi it goes into a boot loop, and when I check my SD card on my PC it’s write protected. And no matter what I try, I can’t unprotect it. Is there anyway to recover from this without starting from scratchj? Also, why does this happen, is it an issue with the RPi?

SD cards are not designed to be written to repeatedly. It’s niot your fault, it’s a combination of raspi creating hardware that does this and the database nature of Home Assistane. It always has been a problem. Using your backup may be your only hope. It is why backups off the machine are so highly recommended.They ALL go bad, some sooner than others.

Apart from what said, it’s very advisable to have some kind of UPS on Pi (or any “thing” which runs HA). The fact is that HA is a kind of linux, and linux doesn’t like power outages at all. If using Pi a cheap battery addon from aliexpress will do.
But, go to ssd, long term you’ll definitely benefit.

So you are saying best bet is to get an m.2 tophat and a UPS? But at this point I would have to start from scratch?

Well, if you have a backup then you don’t need to start from scratch, but if you don’t then you’re stuck with “from scratch” work, yes. Your sd card is gone, as you say, so you need to install a fresh copy of HA anyway, then restore from backup. If you install HA on SSD you’ll have way less chance of media dying than SD card, which was never intended for such intensive use.
Regarding UPS - you can buy classic ups, sure, but for Pi there are other ways like THIS.

A better (and cheaper) choice over (any) Pi is used MiniPC (old intel nuc etc…), but since you already have Pi5 then use it.

Hi, welcome to the forum!

You have experienced the hard way what happens using a RPi with a SD card when power suddenly fails.
I don’t think you can recover from this at all and I really hope for you that you have a backup.

Otherwise you are… and there is no other option then to start all over again.
This probably will not happen to you anymore but right now this might be poor consolation…