[SOLVED] Manual file-rescue of malfunctioning SD Card?

So i got a malfunctioning SD Card in my RPI and learned the hard way to find some backup solution for near future.
For now i setup a new openhabian installation on a working sd card and wanted to port over all my openhabian setup to this installation as i still can access the old sd card.
My process was to install openhabian, start it and let it do “its magic”, then i copied over the old sd cards content from “\etc\openhab2” folder as well as “\var\lib\openhab2” to the new sd card, overwriting its content.

Yet it doesnt work, no bindings, no things. Items and sitemaps were done through smarthomeeclipse, so the files are still there. Things have been done through paper UI in the old installation.

So what am i missing, what files do i have to copy over from the old sd card to restore my openhab?

you can try and mount the SD Card from another machine.
If you don’t have a Linux or MacOS machine nearby, you can try DiskInternals Linux Reader for Windows.

then you have to copy:

  • /etc/openhab/*

if you had PaperUI configurations also at least:

  • /var/lib/openhab2/jsondb/*
  • /var/lib/openhab2/config/*

you can Keep /var/lib/openhab2/cache/ and /var/lib/openhab2/tmp/ and probably /var/lib/openhab2/config/ as those will be overwritten.

So, if that doesn’t work… I’m clueless.

no success… i guess sth is missing

edit: i readded the bindings manually and then copied the “etc/openhab2/” files manually to the “openhab-conf” folder by network share. works so far.
i would like to know where the “openhab-conf” network share points to on my RPI, any clue?

You had openHABian from the beginning on your pi?
/etc/openHAB2 is the config path then.

yes i had. but it only started working when i copied all the files to the network share config, not the sd card directly… really strange. Only setback now is that i have to readd all ZWave things and edit them in the config files as zwave changes its id upon reinstallation.

Is there a way i can completely clone my SD Card with the 2 partitions so i can just switch out the cards when they break?
Is there a possibility/ Wiki for using a NAS or external HDD for openhab?

  1. use win32diskimager for a complete clone of your sd card in Windows (be sure to use it again after each change of your config) or be sure all config can be restored. What version of openHABian did you use before?
  2. there a loads of threads in this. Search for "pi sd card"
    One good thread is Thoughts on failing SD card

I didnt change the versions between my restore process, its been 2.2

Thanks for the links, i will look into it.

Then it’s double strange copying back the files won’t work…
just to be sure, you did this, while openHAB server was down?

I copied them back plugging out the sd card using windows…

I tried that. Win32diskimager just allows me to write an image to a device, not to clone one. In addition, my openhabian split my sd card to two partition, a boot and a data partition (rootfs). How can i clone/ backup this? i wanted to put it onto a usb hdd.

This works, just select the first drive letter of the SD card and start the image process. It will say that it writes an image of the size of your complete SD card to your PC.
I then wrote this image to another card, same size, and OH boots up and works the same way.

Holger

thanks for that!

Hi Holger

I know it is an old topic but I somehow got stuck in a similar problem. I made a backup with the openhabian clonde sd card tool. After that I tried to reboot my pi, but now, both cards dont work.

It would be no problem for me to start from scatch, but the problem is, i need the data from the rrdj4 and influx database. Can I access those data with a windows pc.

Configuration was openhabian 2.5.8; Pi 3

BR
Daniel

you would need something to read the linux File System, than you could read the SD Card on any windows machine… something like this: http://www.ext2fsd.com/

If the cards don’t boot, you’d be in for some trouble I’m afraid…
if the cards boot, but openHAB doesn’t start, you still have access to the rrd-file and the influx db.

but if the cards don’t boot, you should try ext2fsd in windows as Bastian just wrote - or mount the card on another pi/linux with an usb-cardreader (which I personally feel works better).

Hi thx

I used the ext2 explorer and it seems that I have acces to the file system. A backup is also on the card.
So I would start from scratch (does it also have to be the exact same version of openhab, or would it be possible to go with Openhab 3?), put the backup on the new openhab system, restore it and then I would copy the databases to the new system? Could it work this way?

BR

Hi Daniel,

if your card got damaged just by reading it out, this is bad. Good luck on restoring your old data. I never have done that…

Holger

This should work, I guess:

  1. restore your backup in a new vanilla OH2
  2. updgrade this OH2 to OH3

I’m not sure, if restoring OH2 config into OH3 works. That’s why I’d go the reroute here.

1 Like

Yes, for now my recommendation would be to restore to the same version of openHAB as was backed up and then update.

I’m hoping to find the time to work on the restore procedure so that its a little bit more effortless.

I’m not sure, how many Users would like to restore from a backup directly to OH3… But if you can make it work, sure there’s some folks using it !:wink:

1 Like