Restore from external SD card

  • Platform information:
    • Hardware: Raspberry Pi4 2GB
    • OS: Openhabian
    • openHAB version: 3.0.1
  • Issue of the topic: Restore from external SD card simulation

Hi all,
I know there are a lot of posts and manuals regarding the backup process but I still can’t figure out how to achieve what I want.
And I obviously did something wrong, I just can’t figure out what…
I have an internal SD card of 32GB, and an external SD card of 64GB (connected through a USB card reader).

After Openhabian installation I did the following:

  1. Connected the USB card reader with the 64GB SD card.
  2. In openhabian-config I selected menu option 53: Setup SD mirroring.
    Three partitions were created in the external SD card. sda1 was very small, sda2 and sda3 were almost 30GB each. I identified sda3 as an empty partition so figured sda2 was the mirror of the internal SD and sda3 is free for openhab-cli backup etc.
  3. Then I started defining my model, items and some pages. (took me a few weeks)
  4. Today I selected menu option 55: Sync SD (thinking it’s going to do incremental backup to the existing backup).

What I wanted to achieve was to have an on going backup to the external SD card so in a case of the internal card would fail, I would:

  1. Take to external SD card to a PC.
  2. Burn an image from sda2 (which I figured is holding the mirrored information from the internal SD)
  3. Burn that image to a new 32GB card and boot from it.
  4. Place back the external 64GB card to keep the backup routine.

My current situation:

  1. All the partitions from the external SD card are gone.
  2. My pi won’t boot up without both SD cards in place.

So my questions are:

  1. First of all, does my desired backup process make sense? Is that the way it should work?
  2. What have I done to mess things up? Was it the rsync process?
  3. How can I revert back to booting from my internal card only?

Thanks a lot in advance!

No. You are supposed to swap the cards. Read the openHABian auto-backup docs how it’s supposed to work.
If you just burn a copy of the first 2 partitions of the external 64G card yourself (rather than do what the docs tell you i.e. use the openHABian menu) and boot from this new card, then your internal and external cards will have the same partition IDs. From there on everything is coincidential and all sorts of weird stuff can happen.
Use blkid in shell to check your partition IDs.

Why you cannot boot with just one card, I don’t know. You probably did something else you didn’t mention. And if your external card really was empty as you say it cannot be needed for booting to work, can it.

You best bet is to take a backup of your openHAB config (openhab-cli backup), copy it off the box to some safe storage, then reinstall openHABian from scratch and openhab-cli restore.
And setup Amanda to have backups so you have better restore options should this happen again.

PS: and please don’t call it ‘backup’. It’s SD mirroring and just confuses readers.

Hi, thank you for your quick response.

I read the docs again. I stand corrected. Don’t know why I miss understood the first time.

I obviously did, I just can’t figure out what. I thought maybe someone has encountered it before and might give me a glue.
Does menu option 55 (Sync SD) do what I thought? Does it have anything to do with the mirroring or backup process? Could it cause the re-format of the SD card somehow?

Thank you for the advice. Just to be clear- the openhab-cli restore part comes right after installation complete, right?

No, it just does rsync. Set debugmode=maximum and you’ll see everything it does.

yes

Hey,
Idecided to go for a different approach. Since I didn’t know what I did the mess things up with my installation I decided to start from scratch. But this time I carefully documented my steps:

  1. Installed from a fresh openhabian image (ver 1.6.3b) on a new 32GB card.
  2. SSH to set basic parameters (Host name, passwords), install extra packages (Mosquitto, Grafana+InfluxDB, Node red)
  3. Install other packages: speedtest-cli, zigbee2mqtt
  4. Insert a new 64GB card with a USB card reader and select menu option 53 from openhabian-config.
  5. Confirmed sda1+sda2 were the mirrored copy.
  6. Mounted sda3 to a folder for a routined openahb-cli backup- a daily backup to this folder.
  7. Enter MainUI and install add ons, things, defining other stuff.
  8. Copy all my items,rules,sitemaps,etc files to the conf folder.
  9. After everything was done and I confirmed all the items are working correctly I ran openhab-cli backup.

At this point I wanted to check waht happens if I boot with just the internal card:
Performed sudo shutdown to power off correctly, took out the card reader, and powered back on.

And again- the system won’t come back online. The GUI is not accessible and also no response with ssh.
After inserting back the card reader and powering back on fhe system went back online.

I intentionally put as many details as I could so that maybe someone can point out a step that may be causing the weird behavior.
Other options are- it’s supposed to happen, or it’s a bug.

Any thoughts would be appreciated.
Thanks.

This sort of approach won’t help in finding the issue as noone can reproduce it.
You need to figure out why it does not boot.
Attach a monitor to see the boot output.
I guess it’s trying to mount a partition
Put in back the card reader then do blkid and cat /etc/fstab and check /etc/systemd/system/*.mount for any mount that points to the external reader.

You nailed it. :grinning:
I removed the mount pointing to the external card and everything is working.
I guess I learned another Linux lesson today…

Thank you very much!!