Migrating HassOS to HA Core

Currently running Hass OS on a dedicated Pi 4. 400+ entities, few dashboards, 40 integrations, 8 add-ons. It’s done a great job for the last 2 years but after 1 memory card corruption and restore I figured it was time to move it over to something more reliable.

New home would be a Highly Available k3s cluster on two hypervisor cluster, I would like to deploy HA Core as a container. I was actually already able to set it up and it’s up and running with the exception of add-ons but all addons will be their own out of the scope of this post.

The issue is with backup restore, and configuration.yaml both are not accessible in HA Core. Restore is not an option, and scp copy of config every time I need to make a change will get cumbersome pretty quickly. If anyone has ideas on how to perform restore on Core (it begs the question why can you backup if you can’t restore) it would be greatly appreciated.

It is in the path you defined when you deployed your container.

You mean HA Container, I guess. You can reuse the official HA image on k3s (I guess), I don’t see why you’d want to create your own “Core” image.

I would mount the HA config directory as an nfs volume, with the nfs server being outside the cluster.
Then, you can access the nfs mount from basically anywhere.

I don’t need to change the image, just restore the current state.

@francisp thank you, I will redoploy with new yaml config and make sure the path is defined

I guess francis meant the path you would use for the “/config” docker volume in a “docker run” or “docker-compose.yaml”.
But that’s no relevant for a k3s cluster, or you’re not there yet?

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: home-assistant
  namespace: default
  annotations:
    reloader.stakater.com/auto: "true"
spec:
  selector:
    matchLabels:
      app: home-assistant
  replicas: 1
  progressDeadlineSeconds: 600
  revisionHistoryLimit: 2
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: home-assistant
      annotations:
        deploy-date: "deploy-date-value"
    spec:
      containers:
        - name: home-assistant
          image: homeassistant/home-assistant:2023.4
          resources:
            requests:
              memory: "128Mi"
              cpu: "100m"
            limits:
              memory: "512Mi"
              cpu: "500m"
          ports:
            - containerPort: 8123
          env:
            - name: TZ
              value: UTC
          volumeMounts:
            - mountPath: /config
              name: home-assistant-content
      volumes:
        - name: home-assistant-content
          persistentVolumeClaim:
            claimName: home-assistant-claim
      hostNetwork: true

This is the deployment.yaml, once it’s live I can ssh into the pod and see configuration.yaml

For semantic, this is the official HA Container. HA Core is pure software installation of python packages via pip, so it would be a custome container, hence my interrogations.

What I was saying is that rather than use a PVC, you could use an nfs like:

      volumes:
        - name: home-assistant-content
          nfs: 
            server: <my-nfs-server>
            path: <my-nfs-share>/HA-Config

That share could be mounted elsewhere as well for easy access to files.
There are also CIFS/Samba volume drivers, but I never experimented with those.

1 Like

Apologies for not replying earlier!
In my research, I read somewhere to avoid mounting SMB of NFS. Can’t recollect the reasoning or shortcomings of that approach, but you are totally right. In this case, it will just make things a lot easier.

The other question that I need to solve before I proceed is how am I going to restore HA given this setup? Once I boot up HomeAssistant in a container the restore functionality is missing, I can’t even restore local backups (tried that to make sure I’m not missing anything) tldr you can backup but can’t restore

A backup contains what is basically the /config folder tarred. Not a big deal to restore…

untarring the ball and replacing files in /config didn’t work

Too bad. A restore is definitely nothing else…