Back up any and all usb sticks with udev

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
4
down vote

favorite
2












I have home server that I use for back up, Iv recently started using multiple shared (as in new one every few days) usb flash drives for some important files. I want to run a script to copy files only from a certain folder on the flash drive. I thought a udev rule would work great, here was what i wrote



KERNEL=="sd?", SUBSYSTEM=="block", ATTRremovable=="1", RUN+="/home/ketterer/usb_mount.sh '%EID_FS_LABEL'"


Then just for testing I wrote this script



#!/bin/bash
LABLE=$1
echo "lable is $LABLE" >> /home/ketterer/prooffile
sleep 15
touch /media/ketterer/$LABLE/test


The idea is that the usb flash drive mounts under ketterer as the label, so i pass the lable to the script and then I can manipulate it, but saddly it doesnt pass the label to the script.
any Ideas?
As funny as it is, I had it work once, I changed KERNEL=="sd?", to KERNEL=="sd?1", this made it work, but only one time and then it would not even do the script after that










share|improve this question























  • Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test
    – Katu
    Apr 10 at 10:53















up vote
4
down vote

favorite
2












I have home server that I use for back up, Iv recently started using multiple shared (as in new one every few days) usb flash drives for some important files. I want to run a script to copy files only from a certain folder on the flash drive. I thought a udev rule would work great, here was what i wrote



KERNEL=="sd?", SUBSYSTEM=="block", ATTRremovable=="1", RUN+="/home/ketterer/usb_mount.sh '%EID_FS_LABEL'"


Then just for testing I wrote this script



#!/bin/bash
LABLE=$1
echo "lable is $LABLE" >> /home/ketterer/prooffile
sleep 15
touch /media/ketterer/$LABLE/test


The idea is that the usb flash drive mounts under ketterer as the label, so i pass the lable to the script and then I can manipulate it, but saddly it doesnt pass the label to the script.
any Ideas?
As funny as it is, I had it work once, I changed KERNEL=="sd?", to KERNEL=="sd?1", this made it work, but only one time and then it would not even do the script after that










share|improve this question























  • Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test
    – Katu
    Apr 10 at 10:53













up vote
4
down vote

favorite
2









up vote
4
down vote

favorite
2






2





I have home server that I use for back up, Iv recently started using multiple shared (as in new one every few days) usb flash drives for some important files. I want to run a script to copy files only from a certain folder on the flash drive. I thought a udev rule would work great, here was what i wrote



KERNEL=="sd?", SUBSYSTEM=="block", ATTRremovable=="1", RUN+="/home/ketterer/usb_mount.sh '%EID_FS_LABEL'"


Then just for testing I wrote this script



#!/bin/bash
LABLE=$1
echo "lable is $LABLE" >> /home/ketterer/prooffile
sleep 15
touch /media/ketterer/$LABLE/test


The idea is that the usb flash drive mounts under ketterer as the label, so i pass the lable to the script and then I can manipulate it, but saddly it doesnt pass the label to the script.
any Ideas?
As funny as it is, I had it work once, I changed KERNEL=="sd?", to KERNEL=="sd?1", this made it work, but only one time and then it would not even do the script after that










share|improve this question















I have home server that I use for back up, Iv recently started using multiple shared (as in new one every few days) usb flash drives for some important files. I want to run a script to copy files only from a certain folder on the flash drive. I thought a udev rule would work great, here was what i wrote



KERNEL=="sd?", SUBSYSTEM=="block", ATTRremovable=="1", RUN+="/home/ketterer/usb_mount.sh '%EID_FS_LABEL'"


Then just for testing I wrote this script



#!/bin/bash
LABLE=$1
echo "lable is $LABLE" >> /home/ketterer/prooffile
sleep 15
touch /media/ketterer/$LABLE/test


The idea is that the usb flash drive mounts under ketterer as the label, so i pass the lable to the script and then I can manipulate it, but saddly it doesnt pass the label to the script.
any Ideas?
As funny as it is, I had it work once, I changed KERNEL=="sd?", to KERNEL=="sd?1", this made it work, but only one time and then it would not even do the script after that







usb-drive udev






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 10 at 18:51









qbi

14.7k860117




14.7k860117










asked Apr 9 at 3:48









Jordan Ketterer

10115




10115











  • Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test
    – Katu
    Apr 10 at 10:53

















  • Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test
    – Katu
    Apr 10 at 10:53
















Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test
– Katu
Apr 10 at 10:53





Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test
– Katu
Apr 10 at 10:53
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1023210%2fback-up-any-and-all-usb-sticks-with-udev%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1023210%2fback-up-any-and-all-usb-sticks-with-udev%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491