[Solved] How to use mirrored backup SD card if internal SD card fails on RPi

  • Platform information:

    • Hardware: RPi 4B
    • OS: openhabian 1.6
    • Java Runtime Environment: OpenJDK 11.0.11+9
    • openHAB version: 3.2 Release
  • Issue of the topic: I haven’t experienced and SD card failure, but want to be prepared for what I’m learning is an inevitable eventuality.

I have set up SD card mirroring using openhabian menu 53, and confirmed that the timers it created are running using systemctl list-timers:

openhabian@openhab:~ $ systemctl list-timers
NEXT                         LEFT                  LAST                         PASSED             UNIT                         ACTIVATES
Sun 2022-01-09 18:49:04 MST  1h 32min left         Sat 2022-01-08 18:49:04 MST  22h ago            systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Mon 2022-01-10 00:00:00 MST  6h left               Sun 2022-01-09 00:00:14 MST  17h ago            logrotate.timer              logrotate.service
Mon 2022-01-10 00:00:00 MST  6h left               Sun 2022-01-09 00:00:14 MST  17h ago            man-db.timer                 man-db.service
Mon 2022-01-10 00:08:04 MST  6h left               Sun 2022-01-09 11:09:49 MST  6h ago             apt-daily.timer              apt-daily.service
Mon 2022-01-10 02:02:35 MST  8h left               Sun 2022-01-09 02:00:49 MST  15h ago            sdrsync.timer                sdrsync.service
Mon 2022-01-10 06:58:34 MST  13h left              Sun 2022-01-09 06:44:49 MST  10h ago            apt-daily-upgrade.timer      apt-daily-upgrade.service
Fri 2022-07-01 01:15:00 MDT  5 months 20 days left Sat 2022-01-01 01:15:44 MST  1 weeks 1 days ago sdrawcopy.timer              sdrawcopy.service

I read in the documentation that if the internal SD card fails, I should “replace the broken SD card in the internal slot with your backup card from the external reader. Get another SD card that matches the size of the backup (now in internal slot) card and use menu option 54 to copy your active backup card back to the new one.”

I currently have a 16 GB SD card in the internal slot and a 128 GB SD card in an external SD card reader in one of the USB ports of the Pi. My expectation was that if the 16 GB SD card failed, I would replace it with a card the same size. But this sounds like I would need a second 128 GB card and going forward I would need them both even though the recommended hardware is a 16 GB card.

Also, I’m a little unclear on how using the mirrored card backups actually works. How can it boot using the mirrored card that has an old full back up and a recent incremental back up? I would think I would need to do something to create the latest complete set from these two.

As I said, I haven’t had trouble yet, I’m just trying to be prepared for when I do. Thanks in advance for any insights and help.

The application isn’t designed to create backups of backup.
So should you be in need (already running off the 128G backup) either get another 128G
or restore your backup to a new 16G or reinstall from scratch there and import your config.

I don’t know what exactly will happen but you can also try this: run off the 128G card, insert another 16G as the backup and use menu 54.
Your 128G backup card first 2 partitions should match those of your internal 16G card, the rest is in partition 3. openHABian might refuse to do anything (because it is not designed for this setup to work) or start copying at least the first 2 partitions then spit some error on the 3rd.
Enable debugmode=maximum so you see the commands that copy the first partitions then you can also replay those manually.

Thanks for the helpful response. I better understand the mirroring function. it is exactly what it says - it mirrors the internal SD card. I performed a simple experiment and shutdown the Pi, removed the internal card, removed the USB SD card reader and put that card in the internal slot. When I powered on the Pi, everything appeared to be there and running just like it was on the original card. (I then switched back to the original internal card and replaced the back up in the USB reader).

I was trying to make it too complicated. It is as simple as it sounds, and that is a great thing.

i have a prob with auto mirroring,I set it up a month ago and today i swap the external card with the internal one.I boots up but it is not up to date, in fact i see my openhab state when i first set up mirroring one month ago.It is like its not makes fresh back ups every day.I check my timers and they seem ok.

openhabian@openhabian:~ $ systemctl list-timers
NEXT                         LEFT                  LAST                         PASSED              UNIT                         ACTIVATES
Thu 2022-05-12 19:00:51 EEST 2h 30min left         Thu 2022-05-12 08:30:35 EEST 8h ago              apt-daily.timer              apt-daily.service
Fri 2022-05-13 00:00:00 EEST 7h left               Thu 2022-05-12 00:00:25 EEST 16h ago             logrotate.timer              logrotate.service
Fri 2022-05-13 00:00:00 EEST 7h left               Thu 2022-05-12 00:00:25 EEST 16h ago             man-db.timer                 man-db.service
Fri 2022-05-13 00:42:47 EEST 8h left               Thu 2022-05-12 03:02:18 EEST 13h ago             firemotd.timer               firemotd.service
Fri 2022-05-13 02:01:14 EEST 9h left               Thu 2022-05-12 02:08:02 EEST 14h ago             sdrsync.timer                sdrsync.service
Fri 2022-05-13 06:58:33 EEST 14h left              Thu 2022-05-12 06:16:03 EEST 10h ago             apt-daily-upgrade.timer      apt-daily-upgrade.service
Fri 2022-05-13 13:04:52 EEST 20h left              Thu 2022-05-12 13:04:52 EEST 3h 25min ago        systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2022-05-15 03:10:09 EEST 2 days left           Sun 2022-05-08 03:10:18 EEST 4 days ago          e2scrub_all.timer            e2scrub_all.service
Mon 2022-05-16 00:44:04 EEST 3 days left           Mon 2022-05-09 00:41:35 EEST 3 days ago          fstrim.timer                 fstrim.service
Fri 2022-07-01 01:15:00 EEST 1 months 18 days left Mon 2022-04-04 16:48:31 EEST 1 months 7 days ago sdrawcopy.timer              sdrawcopy.service

any ideas?

Manually run the service or the script that the sync timer executes, see /etc/systemd/system/sdrsync.service.