Can't move the database in the Virtualbox VM

I don’t know if this is a Home Assistant question or a Virtualbox question.

I’m running Home Assistant 2024.8.3 (the latest version) in a Virtualbox VM.

I want to move my database file so it won’t get backed up when I create a backup. The database is huge and in the event I need to restore everything, I will need the space more than I’ll need the data.

I know better than to try to move it while HA is up and running. The problem is, if I shut it down, it also shuts down the OS, which keeps me from moving the file and updating configuration.yaml to point to it.

So what I did was shut down my home assistant VM in Virtualbox and made the .vdi file available on the host system using vboximg-mount. There were apparently 8 partitions in there, so I mounted all of them looking for the configuration.yaml and found it in one called “vol7”. I mounted the vol7 partition onto the host and made my change to the configuration.yaml file, which was under the supervisor/homeassistant directory (it resides under the /homeassistant directory directly in HA OS). The home-assistant_v2.db file was also in that directory, so I created a new directory and moved it there.

There were no errors whilst doing any of this. However, when I restarted the VM containing home assistant, my changes were not reflected in there. Everything was as if I had changed nothing. I restarted Virtualbox and the VM, but still no change. I re-mounted the .vdi file on the host and my changes were still there. I’m really confused.

I’m sure I have the right file, because when I start the VM the timestamp on that file gets updated. I used find to search for the configuration.yaml file in all of the partitions, and that’s the only place it was found.

Am I approaching this wrong, or am I just crazy?

Instead of jumping through those hoops just stop home assistant with Developer Tools > Services > homeassistant.stop

This stops the Home Assistant docker container without stopping the VM OS.

You can access the OS terminal through VirtualBox at that point, although I’m not sure your strategy on moving the db file will prevent it from being backed up.

Maybe it would be better to configure the recorder and logger correctly in HA.
It is by default often way too comprehensive.

1 Like

I don’t seem to have a Services tab under Developer Tools. All I have is YAML, STATES, ACTIONS, TEMPLATE, EVENTS, STATISTICS, and ASSIST.

I’m not sure what you mean by “correctly”. Can you elaborate? I have it set to record 90 days of history, which is what makes the database so large. I don’t see any settings in these that control backups, though.

Actions. I haven’t upgraded and apparently they have renamed the “Services” tab to Actions.

Services have just recently been renamed Actions, so that is why the confusion.
Can you post a screenshot of where the Services word was used, because that needs to be corrected.:slight_smile:

And what I meant with correct was to set it up to only store the states from the entities you need.
As default it pretty much store everything that looks like a state. My guess is that at least half of the data in the file is uninteresting to you.

Using the homeassistant.stop service was brilliant and worked great. I was able to move the database file and update my recorder yaml to point to it.

However, now I have no History tab and all of my graphs say “History integration disabled”. I’m confused again, because, from what I’ve read, this should have worked. Here is the relevant part of my configuration.yaml:

recorder:
  db_url: sqlite:////data/home-assistant_v2.db
  purge_keep_days: 90
  commit_interval: 30
  exclude:
    entity_globs:
      - automation.keep_*

Where did I screw up?

Can anyone help?