Please help me to restore my HA

Hello,

I deleted a few files directly in HA and it was a mistake. I thought that I no longer needed them because I uninstalled an add-on. Anyway, something went wrong and my HA is not coming back up. It’s been more than an hour now. What can I do? I have access to CLI and I know that somewhere there is a snapshot that I can use to restore everything. I can also connect using Putty because my Terminal & SSH add-in works.
image

ha snapshots --help
image
or even better…
ha snapshots restore --help
image

1 Like

Thank you. How can I get a list of my snapshots? I know the name of the latest snapshot that I used, but it cannot recognize it. I guess, it has internal names like “cla07617”

I found this information. Trying to restore now.

hassio CLI
ha> snapshot list

add-ons that get me out of these sort issues
File Editor, Samba Backup, Samba Share

Thank you. How long should it take. I ran restore command about 30 minutes ago and nothing changes on the screen. I guess, it should reboot and come back up but it does not.
image

Have you try ha> host reboot

Nothing changes. In addition, I tried to restore the snapshot with version 2021.6.6, but this picture still shows me version 2021.8.6.
image

try updates
ha> core update --version 2021.6.6
do you have access to samba?

I had to leave. I will try it when I get back home.

I have access to Samba and I see all files including backup files.

look in config/home-assistant.log see if it give you some idea what is the problem

I ran “ha> core update --version 2021.6.6” but nothing changed.

image

Here is my home-assistant.log file. There are some errors. What can I do to fix the issue?

2021-08-12 21:30:00 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly
2021-08-12 21:30:01 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=76 from 2021-08-12 22:19:38.308527)
2021-08-12 21:30:03 ERROR (SyncWorker_1) [homeassistant.util.json] Could not parse JSON content: /config/.storage/core.device_registry
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 32, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1891 column 13 (char 67240)
2021-08-12 21:30:03 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 32, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1891 column 13 (char 67240)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 322, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 314, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 108, in run
    return asyncio.run(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/src/homeassistant/homeassistant/runner.py", line 94, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 129, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 239, in async_from_config_dict
    await _async_set_up_integrations(hass, config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 531, in _async_set_up_integrations
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 633, in async_load
    await hass.data[DATA_REGISTRY].async_load()
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 486, in async_load
    data = await self._store.async_load()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 108, in async_load
    return await self._load_task
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 113, in _async_load
    return await self._async_load_data()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 127, in _async_load_data
    data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 38, in load_json
    raise HomeAssistantError(error) from error
homeassistant.exceptions.HomeAssistantError: Expecting value: line 1891 column 13 (char 67240)

First are you sure that is the working snapshot?
Copy and save the all snapshot to PC
Try Delete
config/home-assistant_v2.db
config/.storage/core.device_registry
and reboot

if that dont work I would just start from begining again, and when you are in the new HA upload and restore the saved snapshot. If its a working snaoshot is should put you back to where you are

I found a way around the problem. I emptied /config/.storage/core.device_registry file and put only

{ }

in that file. After reboot, my GUI came back up and I was able to restore everything using my snapshot.

Thank you everyone for your help.

Dude

The 1st Add-Onn you HAVE to have is a Google Drive SnapShot Add-Onn.

I did break my HA on a number of occations trying to figure out exactly how what works. To reinstall (running on a dedicated computer based server) download my snapshot from Google Drive, upload it to the fresh HA install, and restore it, 40min flat. Youre up and running as if nothing went wrong.

If your running a RasbPi with an SD card, consider moving over to an old Laptop, or maybe even installing a HAT to your Pi running a SSD. Data write and rewrite all the time on a SD card, wears them down quickly.

“Samba Backup” add-ons from the official add-ons store can schedule backup regularly in the background to a network drive.

I have a similar problem and feel this is worth a try. How do you empty the core.device_registry file?

You open it with your file editor.

Thanks a lot for the reply. I’m a total newbie so unsure how I open the file editor from HA CLI?