Hello,
I’m not sure if it’s the nature of this forum to answer this type of question, but my distrib is KDE Neon and not Kubuntu, so I’ll start here instead
I use Neon stable, I have written a script to backup my personal data using “mount”, “umount”, and rsync. The script is supposed to run when I start my PC. The problem is that all of these commands have to be run as a superuser and even though I modified the /etc/sudoers.tmp and successfully checked if the /etc/sudoers was modified, the script doesn’t go through… I added the script itself to sudoers.tmp as follows:
laurent ALL=(ALL) NOPASSWD: /home/laurent/Documents/Informatique/scripts/Sauvegarde_Auto.sh
Then I added the first command of the script with “mount” (I also tried with sudo before “mount”):
mount /dev/disk/by-uuid/df46955c-0503-41fc-a73e-ce3b28911395 /media/
Nothing is working out… I set up a log:
++ date +%A
- jour=Wednesday
- ‘[’ Wednesday = Wednesday ‘]’
- kdialog --yesno ‘Voulez vous faire une sauvegarde?’
++ echo 0- Verif=0
- ‘[’ 0 = 0 ‘]’
- lsusb
- grep -e ‘ID 0480:a00c’
Bus 002 Device 002: ID 0480:a00c Toshiba America Inc External USB 3.0- mount /dev/disk/by-uuid/df46955c-0503-41fc-a73e-ce3b28911395 /media/
mount: /media: must be superuser to use mount.
I’m going to provide the entire script :
#!/bin/bash
set -e
set -u
set -x
sleep 10s
exec &> /home/laurent/Sauvegarde_Auto.log
jour=$(date +%A)
if [ "$jour" = "Wednesday" ]
then
kdialog --yesno "Voulez vous faire une sauvegarde?"
Verif=$(echo "$?")
if [ "$Verif" = "0" ]
then
if lsusb | grep -e "ID 0480:a00c"
then
mount /dev/disk/by-uuid/df46955c-0503-41fc-a73e-ce3b28911395 /media/
rsync -avrz --exclude=".*" /home/laurent/ /media/laurent/ > ~/sortieRsync && kdialog --textbox ~/sortieRsync
rm ~/sortieRsync #&& rm /media/laurent/sortieRsync
kdialog --msgbox "Sauvegarde terminée."
sudo umount /dev/disk/by-uuid/df46955c-0503-41fc-a73e-ce3b28911395
exit
else
while ! lsusb | grep -e "ID 0480:a00c"
do
kdialog --yesno "Le périphérique n'a pu être monté. Vérifier s'il est branché."
Verif=$(echo "$?")
[ "$Verif" = "0" ]
if [ "$Verif" = "1" ]
then
break
fi
done
mount /dev/disk/by-uuid/df46955c-0503-41fc-a73e-ce3b28911395 /media/
rsync -avrz --exclude=".*" /home/laurent/ /media/laurent/ > ~/sortieRsync && kdialog --textbox ~/sortieRsync
rm ~/sortieRsync #&& rm /media/laurent/sortieRsync
kdialog --msgbox "Sauvegarde terminée."
umount /dev/disk/by-uuid/df46955c-0503-41fc-a73e-ce3b28911395
exit 0
fi
else
exit 0
fi
else
exit 0
fi
This script was working fine under Debian12, but I switched on Neon a few weeks ago.
If somebody has a solution, please let me know.
Thank you!