That tecmint article has several serious issues with it (this is reflected in the comments, too). You need a slightly more complex script for what you are attempting. This is based on Attachup, a pyudev srcipt that backs-up a thumbdrive to a computer upon attaching it - but you can make your shell script do whatever you like. https://gitlab.com/slackermedia/attachup ``` KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end" IMPORT{program}="/sbin/blkid -o udev -p %N" # Get label or create one ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k" # mount ACTION=="add", ENV{mount_options}="relatime" ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002" # mount and start backup script## ## replace UUID_OF_PARTITION with the UUID of your destination partition ACTION=="add", ENV{ID_FS_UUID}=="UUID_OF_PARTITION", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/sbin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}", MODE="0770", GROUP="users", RUN+="/usr/bin/mrs-auto_backup.sh" # Clean up after removal ACTION=="remove", ENV{dir_name}!="", RUN+="/sbin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}" # Exit LABEL="media_by_label_auto_mount_end" ``` Replace UUID_OF_PARTITION with the UUID of the partition that you want to backup to. You can obtain the UUID with the ``blkid`` command (make sure the drive is attached at the time). Make sure you are in the ``users`` group (or else use a group that you ARE in). Install that code as a udev rule, and then reboot (I still don't trust udevadm control --reload). When you attach your drive, it will get mounted to /media. Change your backup script (/usr/bin/mrs-auto_backup.sh) so that it back-ups to what gets mounted in /media. I find that this helps ensure a reliable and unique location for your backup destination. Make sure your backup script (/usr/bin/mrs-auto_backup.sh) is executable. Good luck! On Mon, Jul 1, 2019 at 12:40 AM Angelo Moreschini <mrangelo.fedora@xxxxxxxxx> wrote: > > Hi, > in order to backing up data when I connect to computer an USB HD, I wrote the follow UDEV rule : > ------------------------------------------------------------------ > SUBSYSTEM=="block", ACTION=="add", ATTRS{vendor}=="152d", ATTRS{model}=="0578", SYMLINK+="external%n", RUN+="/usr/bin/mrs-auto_backup.sh" > ------------------------------------------------------------------- > the rule is the content of the file : /etc/udev/rules.d/10.autobackup.rules > that I self created . > > I learned this method at the link : https://www.tecmint.com/auto-backup-files-to-usb-media-in-linux/ ("How to backup files to USB media when connected") > > As well I tried in many different combinations and parameters values, never I was able to execute the script inside the rule. > > ----- > In order to get the USB HD characteristic of the USB Hard Disk to use for backing-up the data I used the command : > <sudo udevadm info -q all -n /dev/sdc> > and its output is transcribed below > > Could someone help me to understand because this rule doesn't works ? > > thank you > regards > Angelo > ------------------- > features (attributes) of the USB Hrd Disk that I got with the above command : > [angelo_dev@localhost ~]$ sudo udevadm info -q all -n /dev/sdc > > P: /devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5.1/3-5.1.2/3-5.1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdc > N: sdc > L: 0 > S: external > S: disk/by-path/pci-0000:00:14.0-usb-0:5.1.2:1.0-scsi-0:0:0:0 > S: disk/by-id/usb-JMicron_Tech_DB12345681BC-0:0 > E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5.1/3-5.1.2/3-5.1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdc > E: DEVNAME=/dev/sdc > E: DEVTYPE=disk > E: MAJOR=8 > E: MINOR=32 > E: SUBSYSTEM=block > E: USEC_INITIALIZED=11404758453 > E: ID_VENDOR=JMicron > E: ID_VENDOR_ENC=JMicron\x20 > E: ID_VENDOR_ID=152d > E: ID_MODEL=Tech > E: ID_MODEL_ENC=Tech\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 > E: ID_MODEL_ID=0578 > E: ID_REVISION=0203 > E: ID_SERIAL=JMicron_Tech_DB12345681BC-0:0 > E: ID_SERIAL_SHORT=DB12345681BC > E: ID_TYPE=disk > E: ID_INSTANCE=0:0 > E: ID_BUS=usb > E: ID_USB_INTERFACES=:080650:080662: > E: ID_USB_INTERFACE_NUM=00 > E: ID_USB_DRIVER=uas > E: ID_PATH=pci-0000:00:14.0-usb-0:5.1.2:1.0-scsi-0:0:0:0 > E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_5_1_2_1_0-scsi-0_0_0_0 > E: ID_PART_TABLE_UUID=0007fd62 > E: ID_PART_TABLE_TYPE=dos > E: DEVLINKS=/dev/external /dev/disk/by-path/pci-0000:00:14.0-usb-0:5.1.2:1.0-scsi-0:0:0:0 /dev/disk/by-id/usb-JMicron_Tech_DB12345681BC-0:0 > E: TAGS=:systemd: > > > _______________________________________________ > users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx > To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx > Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx _______________________________________________ users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx