man udev
explica que a chave RUN+=
não deve ser usada para tarefas de longa execução:
This can only be used for very short-running foreground tasks. Running an event process for a long period of time may block all further events for this or a dependent device.
Starting daemons or other long-running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed after the event handling has finished.
A abordagem correta, para sistemas modernos que usam o systemd, é SYSTEMD_WANTS
. De man systemd.device
:
THE UDEV DATABASE
The settings of device units may either be configured via unit files, or directly from the udev database (which is recommended). The following udev device properties are understood by systemd:
SYSTEMD_WANTS=, SYSTEMD_USER_WANTS= Adds dependencies of type Wants from the device unit to all listed units. The first form is used by the system systemd instance, the second by user systemd instances. Those settings may be used to activate arbitrary units when a specific device becomes available.Note that this and the other tags are not taken into account unless the device is tagged with the "systemd" string in the udev database, because otherwise the device is not exposed as a systemd unit (see above).
Assim, sua regra do udev se tornaria:
ACTION=="add", ATTRS{idVendor}=="0930", ATTRS{idProduct}=="1408", SYSTEMD_WANTS="rsync_backup.service"
E você escreve um arquivo de serviço para chamar seu script de backup quando o dispositivo é montado:
[Unit]
Description=Backup riccardo's stuff
Requires=media-Riccardo.mount
After=media-Riccardo.mount
[Service]
ExecStart=/usr/local/bin/rsync_backup_thing
[Install]
WantedBy=media-Riccardo.mount
Quando /media/Riccardo
for montado, seu script bash será acionado.