SD card mirroring and Amanda backup - device files question

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
Description=Run SD raw dump semiannually

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.

Yes: disable the copy services (raw AND rsync).
If you as the user deliberately choose to remove the stick you have to think of and are responsible for doing that yourself.

You are welcome to contribute and come up with a PR.

First, I’m very happy to have this backup options in openhabian. Especially the possibility for create a SD card mirror is very helpfull.

The meaning of my question was one and only to know if there is a mechanism in the backup routine of Amanda / mirror_sd which avoids dumping to a wrong target in case of a damaged / unplugged SD Card mirror. So it seems the answer is No.
My intention is to change the SD mirror target from /dev/sda to /dev/disk/by-id/usb-Generic_Mass-Storage-0:0, which points to /dev/sda. Is this supported to use the /dev/disk/by-id syntax for mirror_sd
/usr/local/sbin/mirror_SD "diff" /dev/disk/by-id/usb-Generic_Mass-Storage-0:0?

No. “Supported” would mean someone intentionally built and tested it to work under these conditions.
You can try to set backupdrive=/dev/disk… it may work or not but supported it isn’t.