How I moved HA to a new host

Initially, I installed HA on a virtual machine of my NAS. The other day I bought Raspberry Pi specially for HA hosting and it became necessary to transfer the entire system to a new host.
Here I decided to tell my experience. Perhaps it will be useful to someone.

Before make migration I STRICTLY recommend to make fresh backup snapshot of you HA configs!

Ok… Login via ssh to the OLD host.

core-ssh:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@core-ssh
The key's randomart image is:
+---[RSA 2048]----+
|        X X XXXXX|
|         X X  XXX|
|        X X XXXXX|
|       X X XXXXXX|
|        X XXXXX X|
|         XXXXX XX|
|         XXX   XX|
|          X X   X|
|                 |
+----[SHA256]-----+
core-ssh:~# cat ~/.ssh/id_rsa.pub
ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@core-ssh

Make clean hassio installation on NEW host.
On NEW host install ssh add-on, configure it (add ssh public key of OLD host) & start ssh add-on.
Then back to console with ssh-connection to OLD host.

core-ssh:~# hassio ha stop
ok
core-ssh:/config# ssh YOUR_NEW_HOST_IP
The authenticity of host 'YOUR_NEW_HOST_IP (YOUR_NEW_HOST_IP)' can't be established.
ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'YOUR_NEW_HOST_IP' (ECDSA) to the list of known hosts.

  _    _                 _
 | |  | |               (_)
 | |__| | __ _ ___ ___   _  ___
 |  __  |/ _` / __/ __| | |/ _ \
 | |  | | (_| \__ \__ \_| | (_) |
 |_|  |_|\__,_|___/___(_)_|\___/



Our Cli:
$ hassio help

debug1: permanently_set_uid: 0/0
core-ssh:~# hassio ha stop
ok

ATTENTION! Be careful with next command. If you run it on the OLD host, it totally destroys all you HA configuration WITHOUT ability to restore it! So… Make backup before migration and check twice on which host you run this command.
For check you can use command ls /backup — if list is empty, but you are make backup before start migration, you’re on the NEW host.

core-ssh:~# rm -Rf /config/* /config/.*
rm: can't remove '.' or '..'
rm: can't remove '.' or '..'
core-ssh:/# logout
Connection to YOUR_NEW_HOST_IP closed.

We’v back to the OLD host.

core-ssh:~# scp -rpC /backup /config YOUR_NEW_HOST_IP:/
debug1: permanently_set_uid: 0/0
modules.xml                         100%  241     6.3KB/s   0.2KB/s   00:00
misc.xml                            100%  294    13.5KB/s   0.3KB/s   00:00
deployment.xml                      100%  348     8.6KB/s   0.3KB/s   00:00
[... many many files ...]
family.yaml                         100%  388    88.2KB/s   1.2MB/s   00:00
.google.token                       100% 1145    24.6KB/s   1.2MB/s   00:00
ui-lovelace.yaml                    100% 3893   220.9KB/s   1.2MB/s   00:00

Done. Ok… Once more time connecting to NEW host and check result.

core-ssh:/config# ssh YOUR_NEW_HOST_IP

  _    _                 _
 | |  | |               (_)
 | |__| | __ _ ___ ___   _  ___
 |  __  |/ _` / __/ __| | |/ _ \
 | |  | | (_| \__ \__ \_| | (_) |
 |_|  |_|\__,_|___/___(_)_|\___/



Our Cli:
$ hassio help

debug1: permanently_set_uid: 0/0
core-ssh:~# ls -a /config
[... List of configs on NEW host ...]
core-ssh:~# logout
Connection to YOUR_NEW_HOST_IP closed.
core-ssh:~# ls -a /config
[... List of configs on OLD host ...]

Is that lists are identical? Are you sure?.. Ok. :slight_smile:

At beginning on the NEW host we need to manually add repositories we use on the OLD host.
Now time to restore our add-ons — come to Hass.io > Snapshots, select last snapshot and restore all, EXCEPT HA itself (because last version has already installed by new host configuration) and HA configs (because we just now copy last configs directly).
And now start HA on NEW host. There are two ways: from this console again connect (perhaps you need to again add the OLD host certificate to the ssh add-on configs) to the NEW host and run command hassio ha start or just reboot your NEW host manually.

And remember to delete certificate of the OLD host from configs of ssh add-on! For security reasons…

Have a nice day!.. :wink:

1 Like