Migrating HomeAssistant server

I’m a geek, you’re a geek, we’re all geeks.

And geeks like their homes to be geeky too.

Back in 2021 this geek installed HomeAssistant on a raspberry pi 2b.

Now… the Raspberry pi 2b is not fully supported by Home Assistant anymore, so anyone doing any serious home automation may want a more official Home Assistant release, or someone may simply want a more powerful server.

Note: in retrospect, even after upgrading hardware, there is no significant improvement on the rapidity or versatility of the server; the pi 2b was plenty powerful for Home Assistant. It is a shame that it is more and more complex to install to this platform, particularly with the current microchip shortage making Raspberries scarce.

The discussion for today will be around Home Assistant migration from one machine to another. This may be a choice from many not only because they are using an old pi and want a more powerful server, but perhaps one has a better machine that rendered itself available. Perhaps one just got a deal on a pi 4. Perhaps it is a way to ensure everything backs-up. Perhaps it is just for experimentation. Nevertheless, here are questions that may arise while migrating from one Home assistant server to another, and how to solve them.

The main idea is not to discuss about the installation process per say. There are lots of articles on the matter already and one very good seggestion would be Matheson Steplock’s article on the matter.

This geek here is retiring the raspberry pi 2b in favor of a small form factor computer onto which Debian was installed. From there, following the Matheson Steplock’s article. to install Home Assistant on this Debian machine, there are concerns and issues.

First of, there is a glitch in the installation process of Supervised Home Assistant’s version 1.3.1 deb file for Debian 11 that causes internet to stop working on the host during installation and prevents completion of the installation. This will be resolved in the future, but in the meantime a Temporary Failure in name resolution occurs, which indicates network interface might be down:

This is bad, but there’s quite an easy solution.

Before doing anything, it is always a good idea to backup some config files BEFORE launching installation:
/etc/network/interfaces
/etc/resolv.conf

interfaces and resolv.conf are overwritten in the installation process – and remove network configuration. More precisely it’s ability to resolve IP addresses. This blocks a command dominoes into blocking the installation.

The idea to prevent this chain of event is to open an SSH session parallel to the Home Assistant installation, have it rooted using “su -” and make it ready to copy the backed up files when the installation process blocks, during the whole process. If any network command fails, copying the files back at the good moment would in theory resolve the issue automagically

If things go according to plan, installation would resume. it’s magic.

Oddly ennough, once all is done, the network still is unfunctionnal…

The files are (still) empty so pushing the trusty backups in and restarting the network would be the way to go.

Not a new install? here’s what to think about.

While there are tons of ways to install Home Assistant, and tons of OSes onto which to install it, they all discuss the installation from the perspective of “a new installation” – or a “OMFG the pi’s memory card crashed it’s time to start over” installation.

What if there is an installation still running? What is to be done when migrating to another machine?? well, that is today’s topic.

Can two HomeAssistant servers coexist on the same network?

Mainly – does one needs to remove the old server before starting to build the new one?

In theory, both servers could coexist. if addressing the same smart objects, there may be conflicts, but it is OK to assume one can install a new HASS server on the network prior to removing the old one. In fact, there are services in Home Assistant to “sync” servers together, so there is nothing wrong in running more instances than one.

That said, they cannot be on the same IP address – the new machine will need a different IP for the time being. If the smart things refer to the IP of the HomeAssistant server, for instance for MQTT, then the new server will need to be readdressed when the old server is taken down.

Can the configuration from the old server be imported on the new server?

Essentially, can the new machine essentially continue where the old one left?

If one uses an HASS OS installation, or a supervised Home Assistant installation, the supervisor makes for easy storage (backup) of the configuration. see HomeAssistant’s article on this topic.

SuburbanNerd published an interesting article on the matter back in 2020. While supervisor and terminology changed, the concept is still valid.

backing up

The backup files are stored in a new “backups” subdirectory in the root of your configuration directory.


It is advisable to store such backup on another storage device in case the server suffer a catastrophic failure. the file can be transferred to another device (such as a NAS) using SSH with Home Assistant SSH addon. Supervisor changed in the last couple revisions of Home Assistant, here is the git page and its instructions on how to properly install the SSH addon.

Hint – if Home Assistant complains that there is no network connection, see above how to revert the network configuration.

Once the new server is installed, first thing to do is install Home Assistant SSH and copy the backup file from the network storage, then proceed to -revert- the backup, on the new installation. of course, this would disconnect the server while it wipes the data and installs the new one; it may take time.

Another option besides SSH is to use Samba, as suggested in Matheson Steplock’s guide. It is much easier and very straightforward to configure.

Are old HomeAssistant backups compatible on newer installation?

Are HomeAssistant backup future-proof? What if there is a need to change version of HomeAssistant, will the old version of the server data still be good?

While no guarantees are made, so far this has been done many times and the configuration always seems to find a way to properly port to the newer software. Home Assistant development seems to keep backward compatibility in mind when updating any of the components.

That being said, the backup file may include HomeAssistant components; it may be wise to pick and choose when reverting from the backup file if the aim is to proceed to an updated version of the home assistant server. The option is there, and partial restore prevents from downgrading a new update.

To note that automations, Lovelace pages and other configurations are part of the Home Assistant components and retrieving this will also bring back the server to the version of Home Assistant of the backup.

It pretty much prevents upgrading and migrating at the same time, particularly if there is a blocking change in the versions of the old server. This is something to consider.

To prevent that, it may be wise to back up the YAML files prior to migrating. Short of that, one can go and copy/paste all config files, or browse trough the backup .tar file and pick and choose what to migrate – to be done trough SMB or SSH.

Once the new server is functionnal, it is possible to run in parallel for a while to ensure all is good. Then change the IPs and validate everything followed.

For this migration, the Raspberry pi 2b was retired after an auto update broke the supervisor, and a new, more powerful machine was entered into service in it’s place. Performance wise, there was not much of an improvement, even if the Debian machine has twice the memory and twice the processor capability of the Raspberry pi 2b, which is surprising. It may depends on what Home Assistant runs, so YMMV…

Related articles

Setup HomeAssistant on an old Pi (Wereallgeeks)
Raspberry Pi (wikipedia)
Install HomeAssistant (supervised) on Debian (Matheson Steplock)
Installing Home Assistant supervised on Debian 11 (community.home-assistant.io)
Backup (Home Assistant)
HomeAssistant Backup and Restore (SuburbanNerd)
SSH to HomeAssistant (Wereallgeeks)
Terminal and SSH addon (git)

Advertisement

Geek talks

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s