Mistakenly deleted configuration.yaml

I mistakenly deleted contents of configuration.yaml using Studio Code Server. I have not restarted HaOS yet and run a check and got the following errors:

➜  / ha core check                  
⣷ Processing... 
⣾ Processing... 
⣻ Processing... 
⡿ Processing... 
Processing... Done.

Error: Testing configuration at /config
INFO:homeassistant.helpers.storage:Migrating core.device_registry storage from 1.8 to 1.9
INFO:homeassistant.helpers.storage:Migrating core.entity_registry storage from 1.15 to 1.16
Fatal error while loading config: 'NoneType' object has no attribute 'items'
Failed config
  General Errors: 
    - 'NoneType' object has no attribute 'items'

Successful config (partial)

What have I done and how can I fix this?
Anyway to restore? Studio code server keeps reversions history?

Thanks.

If you have an unencrypted backup, unzip it and copy over the configuration.yaml file from there. Do not restart until your system passes a config check

I never setup backup. Does the system backup in standard install?
I have just setup a automated backup but that is after the fact.

Is there anyway to get the running configuration content from the system before restart to restore them to configuration.yaml file?

Thanks

No, it doesn’t.
Are you telling me you have never done a manual backup of your system?

Never did it. It is a new install and not much on it. Some lights and Aqara cube.

How does the system function if the config is not loaded in RAM or running memory?

Ohoh, sorry Bruce B,

Time to install again, I would suggest.

And start a backup before you do any serious adding of stuff.
All the backups made using automatic are encrypted. Backups made manual, which is the system that was available previously, you control that.
The entire first hour explains backup very well… Jump link:

1 Like

I have no idea, but given there isn’t much to lose, you could try to add a basic config file so you’ll at least have frontend access.

Here’s a trimmed down version of mine. Hopefully it’ll avoid having to start from scratch:

default_config:

frontend:
  themes: !include_dir_merge_named themes/

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
light: !include devices/lights.yaml
sensor: !include sensors.yaml
binary_sensor: !include binary_sensors.yaml
mqtt: !include mqttsensors.yaml

TBH, if they just started, start with just the first line. All the others listed here require other files to be valid.

1 Like

Hmmm…thanks for the input.

An unprotected file can break HaOS that easily is quiet crazy to have in a system like this.

But there has to be a place in HaOS that shows running config this moment because everything still works. Are configs in a database?

The “ha core check” shows exactly where the issue I think (the helpers…). Again, I am surprised that these info is not enough to rebuild the file.

Or rebuild the file by restoring running configs back to the file.

A full re-install of HaOS is a very funny process for this issue.

The operative configuration is obviously in RAM, but not in the format of configuration.yaml. A typical configuration spans many .yaml files, !include statements, and a combination of formatted (and commented) YAML and Jinja code, some of which is consumed not by HA itself but by third-party integrations. Plus some configuration can be done either in YAML or in the UI, and is encoded differently depending on where.

A user-friendly tool to somehow glean all of that from a running instance and put it into a format that can be read at startup is a tall order, but that’s what you’d need in order to recreate the file you inadvertently deleted. Reinstalling HaOS, especially when you haven’t done that much to customize your system, is honestly a really small effort by comparison. And you can avoid ever needing to do it again by setting up backups.

1 Like

Yes, because of all the HA files, you went and deleted the most important one.

No, they are in the file you deleted. Everything still works because it grabs those instructions at boot.

I gave you a copy of my file to work with. Just save it as configuration.yaml and copy it to your install. Run configuration check, fix issues if found, done.

Stop with all rebuilding from running configs nonsense.

Not as funny as not having ever made a backup, then nuking the most crucial file, yet here we are

What if you just create a new file and restart. It’ll move you on a little from having to reinstall.

Sorry, was that a question? I don’t have the experience. Everyone seems to be saying reinstall is needed at this point.

Unprotected files :slight_smile:

I think Studio Code Server has file revisions outside of HaOS but as an add-on does not have.

Just a figure of speech. At this point what have you got to lose by creating a blank file called configuration.yaml. I think everbody is very interested to see what happens when you try to reboot.

I do have a blank file. Apparently, that would break the system at startup. Other posters say it should include content. You see now?


Above is the least you can have on the file. Everything else you may have had on the file is gone.

Vscode has feature for file history, if you deleted part of the file’s contents and not the entire file. So theoretically you would find the deleted content there

So how is people going to work with the file if is protected?
Although not. As frequently as before, but sometimes you need to do something in there or look something up.

There are many way to protect the files.
1- Keep revisions
2- Create backups as system default
3- Add a notification at top of the file that warns
4- Don’t make the system so complicated that finding info to rebuild the system configuration would be hard
5- Have a running config that is easily downloadable (Cisco routers for example…)
6- Use files but upload settings to DB or vice versa for backup

And there are many more ways that programmers can think of to make this work. It will happen eventually. It will be a matter of time.

Backups are can be scheduled. But you have to do it.
Rest of it is like… yeah… or just don’t delete files.
Seriously where is your own responsibility?

I don’t know where or how you deleted but I get a “are you sure?” each time.