I want to migrate my openHAB 4.3.9, which is currently running on a Raspi 3 with openhabian, to a current Docker container on my Ugreen NAS, but I’m having trouble with the backup/recovery.
Backing up to openhabian is easy, but importing to the Docker side doesn’t work because there’s no way to import the archive there, either via the UI or via the openhab-cli console.
If I simply copy the backed up files to conf and userdata of the new Docker instance, the new installation no longer works. For example, some add-ons are missing and can no longer be installed (i.e. network and modbus).
The error “Could not determine addons folder, its content or the list of installed repositories!” appears.
No, I’m using 4.3.9 on the Raspi, which is the latest version that still supports 32-bit. From 5.0 onwards, I would have to update to 64-bit, which my Raspi 3b can no longer handle. In Docker, I’m using the “latest” version 5.1.2.
However, with the help of the article Article 136995, I was able to fix the problem with the add-on installation.
What I’m still missing is a real bash shell.
I only get the openhab-cli, which doesn’t seem to know how to backup and restore. But that doesn’t seem to be common in Docker either. Or have I overlooked something?
I would still need to integrate a USB device for the electricity meter.
A container isn’t a VM. Part of the point of containers like this is you should only rarely be doing stuff manually inside the container with a shell like that in the first place. And openhab-cli doesn’t exist for manual installations of openHAB. So that’s two reasons why opnhab-cli is not available.
Backup and restore is largely on you, but it’s super easy. You mount some volumes into the container, right? Well those volumes are what you need to back up, mainly userdata and conf. I set up a cron job on the host to periodically tar these folders up but you can do what ever makes sense.
Note that the container automatically takes a backup for you on every upgrade. It puts those in userdata/backups.
But, if you really want a shell in the container, it’s there.
docker exec -it openhab bash
This assumes your container name is “openhab”. Note, not all containers are going to have bash. Many go to extreme lengths to only include what’s needed to run the application in the container and will remove extraneous stuff like extra shells and the like. But the openhab Image, for now at least, still includes bash.
But note, the only changes you make that will persist between containers will be what’s saved to those mounted volumes. And those files are already available on the host.
Thanks for the tip.
The shell is actually hardly usable, as it doesn’t seem to be designed for customization.
Maybe docker isn’t the right solution for me at all,
since I used openhabian before.
For example, I’m missing the mqtt broker mosquitto, but of course I can install it as my own docker container.
openHABian provies an all-in-one preconfigured operating system.
A Docker image gives you (or at least it’s supposed to give you) just barely enough to run a single service and nothing more, and you interact with that service through the mounted volumes or through the service’s API.
If you need more than one service, you run multiple containers, one for each service.
You could even bring them all up as a “unit” using a Docker Compose file.
You do not usually “log in” to a Docker container and muck about in a shell. You do not usually run more than one service in a container and in fact it’s particularly difficult to do so.
These restrictions come with a lot of advantages. But if you are looking for an openHABian type experience, Docker is not going to be able to give you that. You would be better off running a Debian VM or possibly even an LXC (LXC containers behave a little more like a VM supporting logins and shells and all that sort of stuff) with openHABian manually installed instead.