I want to copy a directory and its contents to my external USB hard drive when I connect it to my laptop automatically.
So, I created a file called 00-usb-backup.rules
on /etc/udev/rules.d
with this content:
ACTION=="add", ATTRS{idVendor}=="0480", ATTRS{idProduct}=="a208", RUN+="/home/fabio/bin/backup"
The backup
script has permission to run as a program. And its content is:
#! /bin/bash
cp -r /home/fabio/Ads/ /media/fabio/BACKUP/teste/
Following the answer on another thread, I edited visudo
and added the following on the last line:
fabio ALL=(ALL) NOPASSWD: /home/fabio/bin/backup
But when I connect the USB hard drive nothing happens. :(
Any ideas on what could be wrong?
Thanks!
~/.backupme
~/.backupme
This way, when USB connects, your UDEV will add which sdX has been plugged in. Your cron script will look for the mount point accordingly (you can grep on mount for that device) and then copy files accordingly.
– Joaquín Ayuso de Paúl Nov 13 '19 at 03:38