Moving HA to docker, trying to restore a backup

Hi All
Sorry, i am very new to this, so may ask stupid questions.

I have recently set up a HA installation on Windows using VIrtualBox to play with the system and see what i could get out of it.
I’m loving it so far and now need to move the installation to a new PC before it gets too out of hand with configuration.

I have built a small Linux server and was hoping to run it via Docker, but its proving to be very difficult for me to get working.
I cannot find anywhere to run a restore of the backup.

All the instructions say you can do it from the first login screen, but the option is not there.
Next it says you can run it from the Supervisor UI at any time. Cant find this.

I have found a post on YouTube that shows the Restore is now done from the Backup section using the 3 dots in the corner. This is present on the current VM install, but i cant find it in the Docker install i want to move to.

I am pretty sure i am doing something wrong, or have missed a step, but i have been trying for over a week now, so any advice would be appreciated

TIA

2 Likes

Homeassistant container does not include the addons or supervisor, it is the core Home Assistant only.

If you want to restore a backup to Home Assistant container, you need to copy the entire config directory to the new machine, and then specify the path to the config in the docker run command.

For example, if you copy the config files to a directory on the new machine called /home/booti101/homeassistant, you would have a docker run command like this:

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=MY_TIME_ZONE \
  -v /home/booti101/homeassistant:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

Your new install would then point to the copied over/old files and then it would restore it.

However, if you rely on the addons, you would either need to install them as separate docker container installs yourself, or go with a VM option to use the full version of Home Assistant on the new linux server.

*if your backup is a .tar file you will need to extract the files in the directory on the new machine you map the volume to in the docker run command to have them all restored on the new machine. Here’s a link on how to extract the .tar file - https://linuxize.com/post/how-to-create-and-extract-archives-using-the-tar-command-in-linux/#extracting-tar-archive

1 Like

Thank you
I am hating the week i have wasted trying to find this restore option, but at least i know it wasnt something i was doing wrong.

I dont think i am using any addons, but who know what the future brings.

Right, off to do a little more reading on the wonders of Linux and extracting files :slight_smile:

I run Homeassistant in docker and started that way. It definitely is a learning process and most tutorials out there on youtube are not for this type of setup. It has advantages like being able to install more programs on the same machine, but there are alternatives like the VM setup to do that as well. There’s a lot of posts on here (this one recently VM or Docker ) debating the install types .

He has several good videos about a container install too if you want to check them out:

If you proceed with the docker route, I highly recommend Portainer, which will give you a nice UI to manage docker instead of needing to rely on the linux command line, his other video mentions portainer:

Yes, after a lot of reading, testing and multiple reinstalls, i have been using his blog and videos to get this far (mostly the bottom one)

Thank you for your help earlier. I have been trying this method all night and still cant get it to work
I have backed up the old server, extracted all the files in the homeassistant.tar/homeassistant/data folder and then copied these to the folder on my new server, as suggested.

I have restarted HA on the new server, i have checked the configuration, i have removed and reinstalled the container it to see if it would pick up the data on first creation.
It is doing something, as it is pulling in a sensor list from the configuration.yaml file, but all the dashboards are missing, HACS, integrations

Starting to think it will be quicker to start from scratch and just see if i can replicate what i have done so far.

Some of the files are root files, so it could be a permission issue with them not all copying.

Try using “sudo” when you unpack the tar file or copy things over to make sure all root files copy.

You may need to chown the root files to your user name to get them to copy

1 Like

I gave up in the end.
I have installed VirtualBox on the new Linux server and just exported / imported the instance i was testing on my Windows PC.
Seems to be working and has brought all my data and settings across.

Docker seems great, but i dont think its for me in this situation (might try it with PiHole later on)
I am new to Linux and also at that novice stage of HA where i am screaming at the screen in frustration that they have a backup process built in, but its useless if you can then never restore that data if needed.

I’m sure virtualbox will work fine, and sounds like it was much easier. There are many ways to run homeassistant and ultimately one has to choose what’s best for them based on ease of use, efficiency, etc.

Fortunately you can still run docker next to the VM and install other docker programs as you become more comfortable with it. The only downside to the VM/docker setup I would see would be some slight sacrifices with increased memory and processing power to support putting up the seperate VM. Depending on the processing speed/memory of your server, you might not even notice though.

This works for me Thanks !

I was trying to restore a config from a docker container to another. Copying using sudo was the right way to do it : all files are kept under root’s ownership !

I am now able to save and restore configuration by simply copying the config folder!

I feel your pain mate, I had the same problem, I spent 2 days transferring, tried different options, but finally I got it, the answer even after 2 years seems long, but maybe it will help someone.
Options that did not work for me:

  1. transfer the folder to the server and start a new docker (only some components remain)
  2. make a copy of docker and run it on the server (all from scratch)
    The option that worked for me:
  3. Transfer only the backup file from the old server to the new one, then unpack it and run it
cd /home/<username>/servers/backup
tar -xvf 6972b2be.tar
tar -xzvf /home/<username>/servers/backup/homeassistant.tar.gz -C /home/<username>/servers/backup/

specify the name of the folder in which it was unpacked, or as in my case it was renamed config

docker run -d --name homeassistant_new --restart=unless-stopped -v /home/<username>/servers/backup/config:/config --net=host homeassistant/home-assistant:latest

This allowed me to run a container that had all the same settings as on the old server

1 Like