Manually Migrate OH3 config/settings to new Device?

  • Platform information:
    • Hardware: RPi3B+
    • OS: Openhabian (originally installed early 2021, up-to-date as of about a week ago)
    • Java Runtime Environment: Can’t remember, would need to boot into it and check
    • openHAB version: 3
  • Issue of the topic:
    Out of town, couldn’t connect to myopenhab.org instance. Returned home, local OpenHAB RPi device not booted, showing error of:
Kernel panic - not syncing: VFS: unable to mount root fs on unknown-block(179,2)

Bad filesystem…maybe a power blip while we were out of town? Anyway…

Grabbed the SD Card that was booting the RPi and connected it to a Linux machine with a SD Card USB adapter. Attempting to repair the SD Card results in:

sudo fsck -f -y /dev/sdb
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdb

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a dos partition table in /dev/sdb

I might mess around a little more to try and recover this, but did have a 2nd SD Card connected to the RPi and previously used the CLI backup tool to clone the SDCard. However, trying to boot from the backup card gave a blank screen. Inserting that 2nd SD card (which should have been a clone) into a Linux machine, there are no partitions or data…guess the backup didn’t successfully complete. Maybe the original card was already going bad?

Regardless, If I’m not able to recover the boot file system, is there a way to manually copy over all my configs to a fresh install of OH (outside of the normal suggestion of the CLI backup/restore tool since I can’t boot right now)? It does look like the partitions and files/folders themselves are still available on the original SD Card.

Thanks in advance!

Ugh, that sucks. Is there a chance that you used the openHABian backup/restore at some point? If so, there may be a zip file on the SD card that you can grab and use as the basis for restoring a new system. If not, maybe you can make one and trick the new system into restoring from it.

The zip backup contains copies of your conf and userdata directories. The first one has your text config files, and the second one has your JSON databases. There’s also a file called backup.properties. Mine has this content:

version=3.1.0
timestamp=21_11_20-20_31_58
user=openhab
group=openhab

In theory, you could make a zip file with those two directories and this file, and then use it to restore after you set up a new openHABian (using the sudo-openhabian backup/restore command). I’m just guessing at this, though. No idea if it’ll work.

Once you’re back up and running, you might want to look into doing your backups with the Amanda and disk-mirroring options built into openHABian. I periodically take my SD card out and use Win32DiskImager to save a copy so that I can produce a new card at any time. I just like having it stored on a separate hard drive.

If you want to add a UPS in the future, I wrote a guide for connecting it to OH with Network UPS Tools.

Good luck!

Tried imaging openhabian a couple of times to the “spare” SD card (the one that should have had a clone on it), and Etcher keeps erroring out on the verification phase. Looks like partitions and data were copied to the card correctly, but not trusting it with errors. Possibly a bad card, thus why the backup/clone didn’t take.

I think that’s my last spare SD card, so will get a couple of new cards in and try image again. Don’t want to blow away my existing (although non-booting) one until a new image is up and running so we can try the manual transfer trick.

Will post back as soon as I have something new to work with…