Openhabian auto backup problem

  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: Openhabian
    • Java Runtime Environment: Zulu 11
    • openHAB version: 3.1

After setting up my Openhab on a new SD card, I wanted to activate the SD card mirroring feature from openHABian. The second SD card is also new, both are highend-ones from SanDisk. The config files are already backuped with another script, so mirroring is a good addition for me.

Using option 54 (Raw SD card copy) works fine but the generated SD doesn’t boot (maybe an effect of a lot trying around, do I have to repartition the card somehow?). When I use option 53 “Setup SD card mirroring”, it doesn’t work. After having the same error as in this thread I also updated openHABian-config to the main branch. Now I get the following output:

openhabian@openhabian:/mnt $ sudo openhabian-config 
2021-10-10_08:02:30_CEST [openHABian] Checking for root privileges... OK
2021-10-10_08:02:32_CEST [openHABian] Loading configuration file '/etc/openhabian.conf'... OK
2021-10-10_08:02:32_CEST [openHABian] openHABian configuration tool version: [main]{2021-10-08T08:54:13+02:00}(aa64c8a)
2021-10-10_08:02:32_CEST [openHABian] Checking for changes in origin branch main... OK
2021-10-10_08:02:36_CEST [openHABian] Switching to branch main... OK
2021-10-10_08:02:48_CEST [openHABian] Setting up automated SD mirroring and backup... OK
Taking a raw partition copy, be prepared this may take long such as 20-30 minutes for a 16 GB SD card
FAILED (set random UUID)
mount: /storage/syncmount: wrong fs type, bad option, bad superblock on /dev/sdb2, missing codepage or helper program, or other error.
sed: can't read /storage/syncmount/etc/fstab: No such file or directory
umount: /storage/syncmount: not mounted.
OK (dirty bit on fsck /dev/sdb2 is normal)
OK
OK
2021-10-10_08:55:50_CEST [openHABian] Checking for default openHABian username:password combination... OK
2021-10-10_08:55:50_CEST [openHABian] We hope you got what you came for! See you again soon ;)

It’s not totally clear but it seams that it didn’t work. What could be the problem?

Thanks in advance!

Nobody? Does this mean this feature works perfectly for everybody else, or does it mean nobody else is using it?

Who do you expect to reply to such a question?
If anything it means you did not provide enough information to debug why it didn’t work in your case. Read the debug guide how to provide a useful log and state the exact card sizes.

I’m sorry, I was expecting maybe somebody who has had the same problem, or somebody who didn’t have it but is more knowledgable than me in Linux and/or openhabian belongings and would have some ideas. I am just a simple user and didn’t know about the debug guide.

The sizes of the cards are identical:

openhabian@openhabian:~ $ sudo blockdev --getsize64 /dev/sdb2
[sudo] password for openhabian: 
31642353664
openhabian@openhabian:~ $ sudo blockdev --getsize64 /dev/mmcblk0p2
31642353664
openhabian@openhabian:~ $ 

Now I set the debug level to maximum and tried again, here is the result. For me it’s still not clear what the problem is, I hope the more detailed log helps you others to point me in the right direction:

+ select_blkdev '^sd' 'Setup SD mirroring' 'Select USB device to copy the internal SD card data to'
+ [[ -z 1 ]]
+ array=()
+ declare -a array
+ read -r id foo foo size foo foo foo
++ lsblk -i
++ tr -d '`\\|'
++ grep -E '^sd'
++ tr -d '\\-'
+ array+=("$id" "$size")
+ read -r id foo foo size foo foo foo
+ array+=("$id" "$size")
+ read -r id foo foo size foo foo foo
+ [[ 4 -eq 0 ]]
+ (( count=4 + 8 ))
++ whiptail --title 'Setup SD mirroring' --cancel-button Cancel --ok-button Select --menu '\nSelect USB device to copy the internal SD card data to' 12 76 0 sda 7.6G sdb 29.7G
+ retval=sdb
+ dest=/dev/sdb
+ [[ /dev/mmcblk0 == \/\d\e\v\/\s\d\b ]]
++ blockdev --getsize64 /dev/sdb
+ [[ -n 31914983424 ]]
+ mount
+ grep -Eq '$dest[12]'
+ [[ -d /storage/syncmount ]]
+ [[ raw == \r\a\w ]]
+ for i in 1 2 3
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p1'
++ blockdev --getsize64 /dev/mmcblk0p1
+ srcSize=268435456
++ blockdev --getsize64 /dev/sdb1
+ destSize=268435456
+ [[ 268435456 -lt 268435456 ]]
+ for i in 1 2 3
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p2'
++ blockdev --getsize64 /dev/mmcblk0p2
+ srcSize=31642353664
++ blockdev --getsize64 /dev/sdb2
+ destSize=31642353664
+ [[ 31642353664 -lt 31642353664 ]]
+ for i in 1 2 3
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p3'
+ continue
+ [[ true == \t\r\u\e ]]
+ echo 'Taking a raw partition copy, be prepared this may take long such as 20-30 minutes for a 16 GB SD card'
Taking a raw partition copy, be prepared this may take long such as 20-30 minutes for a 16 GB SD card
+ cond_redirect dd if=/dev/mmcblk0p1 bs=1M of=/dev/sdb1 status=progress
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ dd if=/dev/mmcblk0p1 bs=1M of=/dev/sdb1 status=progress \033[39;49;00m'

$ dd if=/dev/mmcblk0p1 bs=1M of=/dev/sdb1 status=progress 
+ dd if=/dev/mmcblk0p1 bs=1M of=/dev/sdb1 status=progress
260046848 bytes (260 MB, 248 MiB) copied, 12 s, 21.7 MB/s
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 26.0704 s, 10.3 MB/s
+ return 0
+ cond_redirect dd if=/dev/mmcblk0p2 bs=1M of=/dev/sdb2 status=progress
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ dd if=/dev/mmcblk0p2 bs=1M of=/dev/sdb2 status=progress \033[39;49;00m'

$ dd if=/dev/mmcblk0p2 bs=1M of=/dev/sdb2 status=progress 
+ dd if=/dev/mmcblk0p2 bs=1M of=/dev/sdb2 status=progress
31637635072 bytes (32 GB, 29 GiB) copied, 2579 s, 12.3 MB/s
30176+1 records in
30176+1 records out
31642353664 bytes (32 GB, 29 GiB) copied, 2589.64 s, 12.2 MB/s
+ return 0
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p3'
++ blkid /dev/mmcblk0p2
++ sed -n 's|^.*PARTUUID="\(\S\+\)".*|\1|p'
++ sed -e s/-02//g
+ origPartUUID=c59376aa
++ yes
++ cond_redirect set-partuuid /dev/sdb2 random
++ [[ -n '' ]]
++ awk '/^PARTUUID/ { print substr($7,1,length($7) - 3) }'
++ echo -e '\n\033[90;01m$ set-partuuid /dev/sdb2 random \033[39;49;00m'
++ set-partuuid /dev/sdb2 random
mount: /tmp/set-partuuid-mnt: can't read superblock on /dev/sdb2.
++ return 1
+ partUUID=
+ cond_redirect tune2fs /dev/sdb2 -U random
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ tune2fs /dev/sdb2 -U random \033[39;49;00m'

$ tune2fs /dev/sdb2 -U random 
+ tune2fs /dev/sdb2 -U random
tune2fs 1.44.5 (15-Dec-2018)
tune2fs: Bad magic number in super-block while trying to open /dev/sdb2
/dev/sdb2 contains a ext4 file system labelled 'rootfs'
+ return 1
+ echo 'FAILED (set random UUID)'
FAILED (set random UUID)
+ dirty=yes
+ umount -q /dev/sdb1
+ mount /dev/sdb1 /storage/syncmount
+ sed -i 's|c59376aa||g' /storage/syncmount/cmdline.txt
+ umount /storage/syncmount
+ umount -q /dev/sdb2
+ mount /dev/sdb2 /storage/syncmount
mount: /storage/syncmount: wrong fs type, bad option, bad superblock on /dev/sdb2, missing codepage or helper program, or other error.
+ sed -i 's|c59376aa||g' /storage/syncmount/etc/fstab
sed: can't read /storage/syncmount/etc/fstab: No such file or directory
+ [[ -f /storage/syncmount/etc/systemd/system//storage.mount ]]
+ umount /storage/syncmount
umount: /storage/syncmount: not mounted.
+ cond_redirect fsck -y -t ext4 /dev/sdb2
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ fsck -y -t ext4 /dev/sdb2 \033[39;49;00m'

$ fsck -y -t ext4 /dev/sdb2 
+ fsck -y -t ext4 /dev/sdb2
fsck from util-linux 2.33.1
e2fsck 1.44.5 (15-Dec-2018)
ext2fs_open2: Bad magic number in super-block
fsck.ext4: Superblock invalid, trying backup blocks...
rootfs: recovering journal
fsck.ext4: unable to set superblock flags on rootfs


rootfs: ********** WARNING: Filesystem still has errors **********

+ return 12
+ echo 'OK (dirty bit on fsck /dev/sdb2 is normal)'
OK (dirty bit on fsck /dev/sdb2 is normal)
+ dirty=yes
+ [[ yes == \n\o ]]
+ [[ -n '' ]]
+ return 0
+ '[' 0 -ne 0 ']'
+ true
+ show_main_menu
+ local choice
+ local version
+++ get_git_revision
+++ local branch
+++ local commitDate
+++ local shorthash
++++ git -C /opt/openhabian rev-parse --abbrev-ref HEAD
+++ branch=main
++++ git -C /opt/openhabian log --pretty=format:%aI -n 1
+++ commitDate=2021-10-14T12:07:14+02:00
++++ git -C /opt/openhabian log --pretty=format:%h -n 1
+++ shorthash=9bbfa35
+++ echo '[main]{2021-10-14T12:07:14+02:00}(9bbfa35)'

Well it’s part of the docs, with multiple references to in there so I’d say anybody including yourself is expected to know it exists just like any user is expected to read the docs.

I don’t know what your issue is. As you can see in the log, access to the superblock of the 2nd card fails multiple times. So either that or the origin card superblock is broken. I don’t see any openHABian problem.

If you have a working Linux system you can insert the card there and repair the superblock. There are various howtos to be found when googling, like: HOWTO: Repair a broken Ext4 Superblock in Ubuntu | Linux Expresso

I’d rather restart and flash again. If the issue persists, use different cards.

Thanks everyone! Markus was right, the origin superblock was broken. I don’t know how that happened, this system was just set up freshly. After fixing the superblock, the option 54 “Raw SD card copy” ran without errors, the resulting SD card boots fine and the option 53 “Setup SD card mirroring” also seams to run throw fine.

I am getting an UPS and probably also (again) fresh cards, just to be sure.

PS: xkcd: Dark Arts

1 Like

Regarding UPS: while bulky, I am very happy with the Eaton 3S550D. Works perfectly with NUT and runs my NUC, modem, router, etc without problems.

Thanks, I’ll have a look at it.

One last question to the auto backup SD mirroring timers: What is persisted and used for the periodic jobs, the device path (for example “/dev/sda”) or the UUID? Asking because the external SD card is not always loaded with the same device path on my Pi.

device path
you shouldn’t be changing hardware on your server, and when you don’t, device pathes don’t change.

Thanks, I don’t plan to change hardware so I should be fine.