This morning the house circuits that are on my inverter EPS pinged off and then back on again which lost the internet connection and forced a reboot of my home assistant server as these are on the EPS circuit board.
Home Assistant came back OK, but then it pinged off and on and again, and after about 3 or 4 more of these I went and switched the changeover switch so the EPS fusebox was fed directly from the grid and went to look at what HA was telling me. Unfortunately the multiple power cuts had killed my Home Assistant VM and it wouldn't then boot.
Fortunately I use the excellent Google Drive Backup add-on for HA that takes a backup every night and copies it to a dedicated Google drive account I have, ... but when I went to get the latest download I found that the drive was out of space and the last backup taken was on 31st March.
I was able to restore that backup so I lost 3 days of data, but subsequently I worked out how to access and extract the backup taken last night that was in my corrupt HA virtual disk, so here's a brief guide to how to do this if its useful to anyone else.
Needless to say you need to be taking backups, either manually, via the Google drive backup add-on or the Samba backup add-on. I was taking backups they just were not getting saved outside of the HA virtual disk.
I use the free Oracle VM virtualisation software running HA as a VM under Windows 10. If you use a pi or other approach the steps will be different.
Download the latest VirtualBox HASS software and create a brand new HA virtual server
https://www.home-assistant.io/installation/windows#start-up-your-virtual-machineStart the virtual machine and let HA set itself up. http://homeassistant:8123
Get to the point where you are ready to start the onboarding https://www.home-assistant.io/getting-started/onboarding/
If you have a backup on a NAS drive, Google drive or wherever, download the backup onto the Windows PC, select 'restore from backup' and HA will restore the backup and you'll only have lost the data after the last backup point.
In my case I did this OK and HA was now running but had lost all data from 31/3, 1/4, 2/4 and this morning 3/4. I realised that there was more recent backups locked inside the old (corrupt) HA VDI file. Process to get these out is as follows.
Download and install the free DiskInternals Linux Disk Reader https://www.diskinternals.com/linux-reader/ (you don't need the pro version)
Run Linux Disk Reader. First step is to open the (corrupt) old virtual disk. Drives/Mount Image/Containers, select Virtalbox virtual disks (worth noting that Linux reader does support other virtual disk types).
Click Next, navigate to where your corrupted HASS VDI is, select it and click OpenYou'll now see a number of additional volumes for the Linux disks within the VDI. The one you want is the one that contains hassos-data - /mnt/data in my case
Double click the hassos-data volume, then navigate through the supervisor and single click the backup folder. We're going to extract all the HA backups as we can't tell which is the latest
Click Commands/Save, choose where to save the files to, and then let it extract all the backups to the Windows PC.
Having got the most recent HA backups on the PC you can restore that into HA by following step 4 above (or if HA is already running, go to System / Backups, three dots in the top corner, Upload and upload the backup into HA and you can restore it from there).
Hope this helps someone else. I only lost half a day of data as a result of being able to restore from the backup from within the VDI disk
