env: Openhabian on Raspberry Pi3
I‘ve setup an Amanda backup with an USB stick as target and a „SD Mirror“ to an external SD card.
The Amanda backup and the SD mirroring was set up via openhabian-config.
The USB stick is mounted via fstab. Device file for mirrored SD card is /dev/sda, backup USB stick is /dev/sdb
So far all works fine.
But one question comes up:
What happens if the SD mirror card isn‘t plugged in while a reboot.
Then becomes the device file for USB, which is originally mounted with /dev/sdb, /dev/sda.
Ok, the mount will fail, because the fstab has the wrong device file.
But the sdrawcopy.service unit file is
# /etc/systemd/system/sdrawcopy.service
[Unit]
Description=Run SD raw dump semiannually
After=network.target network-online.target
Wants=sdrawcopy.timer
[Service]
Type=oneshot
User=root
Group=root
ExecStart=/usr/local/sbin/mirror_SD "raw" /dev/sda
Regarding the ExecStart line:
/usr/local/sbin/mirror_SD "raw" /dev/sda
will try to dump the SD card to the USB stick which is now /dev/sda and because /dev/sda is hard coded in unit file. Hence the dump command corrupt the USB Partitions.
It would be nice if the mirror_SD would detects a mismatch here and don’t start dumping the SD card.
Is there a concept in openhabian for that case? Is it maybe a feature reuest for openhabian (which is really a great work from yours)?
For my intention I have to make an udev rule for the sd-card which creates a device symlink (linux - How to bind USB device under a static name? - Unix & Linux Stack Exchange).
ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="my_sd_mirror"
This symlink is the new target for /usr/local/sbin/mirror_SD "raw" /dev/my_sd_mirror
Thank you very much.
Peter