Restore HA backup in a new HA-container

Hi there,

I backuped my HA instance that was running on a virtualbox with the plan to restore it in a containerized HA instance.
I understand that for containerized HA setup you can’t restore backups as straight forward as you do that with a non-core installation. So I most likely need to copy files (?) directories (?) backups (?) here and there. - I don’t know acutally.

Any suggestions?

Untar/Unzip in the directory mentioned in your docker compose file or docker run command.

It would help to get your info where the container/volume is stored or how exaclty you have deployed.

for example in my case i deployed it with docker-compose (but plain docker is mostly the same) with following parameters:

services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:latest"
    depends_on:
      - mariadb
      - mosquitto
      - zigbee2mqtt
    volumes:
      - homeassistant_data:/config
      - /etc/localtime:/etc/localtime:ro

[...] removed other things to prevent unnecessary spam [...]

volumes:
  homeassistant_data:

this means it created a volume “homeassistant_homeassistant_data/_data” in

/var/lib/docker/volumes/ directory
on my ubuntu-docker-host which is reachable with root-privileges (i used sudo -s)

So when i look up on my docker host with ls -la i get the “known” structure:

so basically you could unzip your backup and restore the files into the _data-dir of the volume (maybe stop the container before doing this).

Hope this helps.

I deployed mine like this:

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Berlin \
  -v homeassistant_data:/config \
  -v /run/dbus:/run/dbus:ro \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

then (on my windows machine) extracted everything in the tar and moved it over via winscp to the directory: /var/lib/docker/volumes/homeassistant_data/_data
restarted the container and then logged on.

I would expect, that I do not even have to run through the initial onboarding wizard fireing up HA, however I did that. and I looked at a plain installation apart from the automations, which I could see have somehow been restored :confused:

To be honest I dont know what needs to be done to prevent initital onboarding but I think the database had to be migrated too, since everything else is in the DB stored (assumption - correct me when im wrong).

So if you use the default (sqlite?) database it could have been copied 1:1 (overwritten) when the version is identical. But im very cautious about database migrations to be honest.

Using MariaDB might be a lil bit more complicated and I have no idea what needs to be done in that case though.

ok, to summarize the steps I did are “in theory” ok. but somehow the restore by copying over the files does not work. I wonder if there is anyone who was able to do it.