How to access the Backup Files via SD Card

Hey Guys,

so somehow in the last week my Homeassistant shit the bed. I didnt check it this week but somehow the automations.yaml was corrupted (it told me, I didnt change anything in there though). Today I couldnt do anything so I just did a Hard Reset (pulled the plug on my raspi). Now it wont start / connect to the network. Last Weekend I did some Updates so maybe this caused the error (altough im sure my hard reset didnt help).

Now I am wondering if there would be an easy way to access the Backups I created last weekend by Updating the System. I plugged the SD Card into my Windows Laptop but I can only access some files (not EXT4 , etc).

Would it be better to just search the Backup and try to get that running or should I plug the raspi into a display and see what the OS spits out as error message while starting?

2 Likes

You can read the ext4 partitions with the free diskinternals Linux reader.

thank you for the quick response,
the SD Card has a total of 8 partitions.
1 of which I can access with Windows.
2 of which only have a folder “lost and found” and a file called “image”.
The rest cannot be accessed. Linux Reader says:"Cant open disk: Volume 1 (hassos-system0, Linux) Check the disc and try again.

If I connect the pi to a monitor and view the logs it gets stuck at “waiting for the home assistant CLI…” (but ive only viewed it for a couple of minutes, but normally it should have started by now).

If you don’t have an off-SD backup, then you are out of luck.

For the future :

Copying your backups to another location

You often need a backup in case your system has crashed. If you only store them on the crashed device, you won’t be able to access them easily. We recommend that you manually copy them from /backup to another machine on occasion. Or even better, create an automation to handle that, or make use of one of the following add-ons:

If you have another SD card and USB card reader available, you can try flashing that second card with Raspi OS and then put the original card into the reader and try mounting it under RPi OS.

That may be able to mount and access the other partitions as it’s a native Linux environment, and copes with them better than Windows does.

But as Francis says, it’s always best to keep the backups off the device so any failure of the card doesn’t also take them out.

For those finding this again on Google, the solution was:

Using DiskInternals Linux Reader to access the Linux partitions on a Windows machine. I found a partition with the directory (I know this looks odd, but directly copied from DiskInternals software) “/var/log/journal\supervisor\backup”. It has a lot of tar files that appear to match the “slug” values I saw in the HomeAssistant CLI, so I’m sure these are the backups I made.

I can confirm that inside one of the large tar files I found are the following files:

./backup.json
./homeassistant.tar.gz

Unpacking the archive I found all my configuration yml files and a copy of my database. Success!

To unpack a tar into the current directory:

tar -xf homeassistant.tar.gz

6 Likes

I’m in the same boat here. What partition was it on? I can’t find it on any of my partitions but may have overlooked it…

Cheers

I’m assuming the partition is called “/var/log/journal” or maybe just “journal”. I can’t say I’m a Linux partition expert. If you add a screen shot of what you see, I can maybe point you in the right direction.

1 Like

it should appear as “hassos-data” and the proper path would be /data/supervisor/backup/

All the .tar files in there are backups.

3 Likes

Thanks for the replies… I’m starting to think my SD card has just completely failed as when I went to plug it in and have a look this evening, the computer is no longer detecting the partitions. It was a cheap SD card from a shopping centre kiosk I bought one time. Probably shouldn’t have been using it in the first place. Might have to set everything up again and cop it on the chin. Lesson learnt - back up on a separate drive :pensive: I’m pretty sure most of the data was corrupt/gone anyway as I couldn’t find any TAR filesin the system last weekend when it was working.

1 Like

That is exactly what just happened to me right now. No idea why or what the culprit is…
Trying linux reader, but it can’t see the (usb ssd) drive. Windows sees it exists but cannot access it

1 Like

bro, you saved me, thank you with all my heart, i made an account just to thank you

2 Likes

A pleasure, thank you for the feedback

Hi all

So I have been struggling with a corrupted USB drive which used to house my HA instance, running on a Pi4. Found a way to restore it following some of the links provided here and thought I’d share what I did.

I used @zymotik link and created an image of the corrupted drive by right clicking on the drive in the diskinternals UI and selecting “create image”. I saved this image on my Windows PC and then used the Raspberry Pi imager to write it to an SD card. In the imager I chose “custom OS” selected the all files option and chose the “drive.sdk” as the image to write onto the SD card. Put that back into the Pi and it ran 100%.

Thanks for all the help here, without this I would not have been able to do this.

4 Likes

I guess I’m being dense, but I can’t figure out (in diskinternals linux reader) how to get to /var/log/journal\supervisor\backup. I see all the windows files and a warning, “file system not supported” down at the bottom. Can you help?? This is the only solution I can find described on the entire internet!

Nm, I was being dense…for anyone else coming across this, you mount your HA disk image in Diskinternals Linux Reader and then can access the files. For me the supervisor\backups location path was different: mnt/data\supervisor\backup.

I’ve had a home assitant instancve shit the bed. I’ve managed to find the back up tar files through disk internals, but can anyone tell me how on earth to go about restoring? Do I reinstalll HASS and then how do I get the back up files back into the system to restore?

This was beyond helpful, thanks so much. Managed to get HA back up and running doing exactly as you suggested. My SSD had made itself write-protected just a month or so after setting HA up on a Pi4 (it was ancient to be honest), I managed to get the tar backups off it and thought I’d have to restore them after flashing a fresh image, but this was a much better solution!

Now to bump offloading my backups somewhere safe up on my HA to do list…

@Alb51 Well fu****ing done!! Did as you said, and just got everything working back again, as if nothing had happened. My system was running normally, and one morning I woke up with switches not working, I checked and there was the “Cannot connect to the Docker Daemon” error message, the home assistant wasn’t starting anymore, I think my microSD card was the issue, its old and from an uncommom brand. Anyway, just grabbed another micros, follow your steps, and voilá! Thanks for sharing, man!