Migrate from BalenaCloud to OpenBalena remotely

Is it possible to migrate a device from BalenaCloud to a OpenBalena server without being in the same network as the device?

The possibility that I’m seeing is to add and run a script from the BalenaCloud SSH interface, that makes the necessary changes to the config.json file. Is that possible? The script would backup the original config.json and restore it if anything goes wrong.

Another possibility that I’m seeing: there’s always at least two Balena devices in it location. Can I use one device to access and migrate the other one?

Hello, yes the approach you outline should work. Keep in mind, if you are using a later version of the OS, there is a systemd file watcher that triggers on any changes to config.json (it immediately restarts the VPN, balenad, etc.), so please make sure you test your scripts(s) somewhere safe first because if the system can’t register/access the new apiEndpoint in config.json, it will almost certainly become inaccessible.

Other that that, as long as the device is able to access your openBalena instance apiEndpoint using the apiKey in the new config.json, and that instance is configured correctly, the device should disappear (offline) from balenaCloud and appear (online) on your openBalena instance.

The same approach should work in reverse, though since openBalena doesn’t have SSH/terminal, it would make reversing more involved.

Nice! Thanks for clarifying!

I’m curious about your comment regarding SSH/Terminal on openBalena. Does it not support it? I have indeed tried to make it work but was unable to and paused the works on it to focus on the migration script.

The tunnel service works for me in openBalena to ssh to devices. However, I had to ensure during flashing that my ssh key was on the device.

Yes, as long as the public SSH key is registered with sshd on the device, SSH connections can be made over openBalena tunnels.