How to restore backup after upgrading a Docker Home Assistant Container?

To upgrade a Home Assistant Container, in my case using Docker, you stop and remove the container, then set up a new one. This results in a brand-new HA install. My question is, how do I (or can I even) restore a backup previously made in a container? It seems to me that backups are saved in the container (“this system” in the UI), and when the container is removed, so is the backup.

First setup your backups to store outside you container. Easy to do with many ways to do it.

Second copy your latest backup from your container before removing the container, again easy to do from the ui.

If as part of the docker setup you’ve mounted the config directory I think it stores it under backup inside that so is outside the docker container? Check by looking for the backup directory in the config directory its mapped to. That way if you do an upgrade when it replaces the docker container the backups and rest of config is still there.

It’s best for you to have it back up outside of the host on the network/cloud service, then if anything happens you can just restore from that backup. Don’t forget to save the encryption key if it uses that

Your install is misconfigured
Did you use docker run command or compose?

Normally when update docker the /config directory remains unchanged and is permanently minutes on host. The update should not touch this.

You have done something wrong and your / config folder is part of docker or you mistakenly pointed docker to wrong folder. This caused HA to create a new folder

Your original /config folder may still exist but need more details to sort this

1 Like

How? I’m sure there are many ways but I don’t know them or I would have done so. I have just found the “explore more locations” link, but the long and complex instructions to set such storage up isn’t really what I’m after (just somewhere else on the RPi).

I have just found the well-hidden option to download a backup though, so thank you for pointing me in that direction.

Having had a look for it I can now see it storing backups under /home/pi/home assistant/backups. When I went to IP:8123 for the first time to set up the HAC it didn’t see any backups to restore from the previous HAC I had been running.

Now it’s up and running if I go to Settings->System->Backup I can select “upload backup” but the UI only offers to upload a backup from my local system, not from on the RPi. So how do you restore a backup from the RPi’s filesystem?

I copied and pasted the code from Advanced Raspberry Pi installation - Home Assistant . You are wrong in your assumptions.

A few points you may not really like to hear.

1 The docs explain everything I suggest reading them and understanding. If you have an issue chances are it will be explained in the docs.

2 if you don’t have an understanding of how docker works and is setup the advanced installations are probably not the best way to go for you.

3 install following the " DIY with Raspberry Pi" guide here. It will be much easier, just as its designed to be.

1 Like

I’ve read them thank you. I understand how Docker works. If you’re incapable of answering my questions, please stay out of the thread.

Except his response was correct and please check the attitude people are trying to help.

In ha you don’t restore when using docker.

If you’d read docs about backups, you’d notice backup restore is only supported on installs using supervisor. (haos) to. ‘restore’ on Docker container installs you just copy the contents of your config folder (including the hidden stuff) in a correct docker install that’s a redirected folder… Sooo

And yeah something is messed up with your install if it’s behaving as described…

1 Like
  • /PATH_TO_YOUR_CONFIG points at the folder where you want to store your configuration and run it. Make sure that you keep the :/config part.

I hope you replaced /PATH_TO_YOUR_CONFIG
with a real, existing path

1 Like

I’ve read them thank you. I have already linked to them saying I followed them exactly. I understand how Docker works. If you’re incapable of answering my questions, please stay out of the thread.

To be clear: how do you restore a backup after removing an old container and installing a new one?

Unless you purposely deleted your config or incorrectly placed it inside the container, the config will still be there unchanged.

1 Like

As the reply here says:

It’s a compressed zip file, you can just unpack it when you want to restore it.

I’m sorry to say, but you do not understand enough. When you set up a docker, you specify volumes that map folders inside the docker to folders on your host machine. This is specifically related to the config folder. So a new docker should not look like a brand new install, because your config is not really inside the docker. This was explained before.

While backups are crucial, they are not the solution to fixing this misconfiguration. You cannot be sure you had the chance to backup before any reload of the docker, and you’ll always miss what happened just after the backup captured things.

2 Likes

People are trying to help. Please watch the attitude.

As others have said, you shouldn’t need to restore a backup after upgrading/downgrading the container. Properly configured, your configuration will remain untouched. For example, here is my docker compose entry for Home Assistant:

  home-assistant:
    container_name: home-assistant
    image: ghcr.io/home-assistant/home-assistant:stable
    mem_limit: 4gb
    volumes:
    - /opt/home-assistant:/config
    - /tmp/snapshots:/media
    environment:
    - TZ=America/Chicago
    restart: unless-stopped
    network_mode: host

/opt/home-assistant on my server is mapped to /config in the HA container. As long as you have the configuration mapped properly like this (replace /opt/home-assistant with the path you want of course), then your HA config will be unaffected by upgrades/downgrades.

4 Likes

Backup is the config.
In case of docker just place it in config folder location.

“Restore” function doesnt exist in docker for some reason. Normally it should be under settings >> system >> backup I believe