-
Howto run a shellscript in Ubuntu with root priviledges
Okay, shellscript newbie here, but I want to learn it after my big disaster with the bad blocks on my last harddrive.
I have two 120GB harddrives in my case. The first one holds three partitions holding my working system:
/dev/hdb1 is mounted as /
/dev/hdb2 is swap
/dev/hdb3 is mounted as /home
Now for the second 120GB drive, it contains the same partitioning:
/dev/hdd1 is mounted as /backup/system
/dev/hdd3 is mounted as /backup/daten
My ultimate goal is to have a cron job run rsync to sync my files on the "working harddrive" to the "backup harddrive". This works like a charm:
Code:
sudo rsync -Cavz --delete /home/ /backup/daten/
Hence I made a little script which is supposed to mount the partition on the backup drive, run the rsync, and unmount the drive again:
Code:
#!/bin/bash
mount /backup/daten
rsync -Cavz --delete /home/ /backup/daten/
umount /backup/daten
This fails because Ubuntu doesn't mount the drive - only root can do that so Ubuntu exspects sudo to precede mount. However, I don't want to use sudo to ask me for my password since the whole thing should be non-interactive as it's supposed to be run as a cronjob later. BTW, root is the owner of the script. So, how can I make this script mount my harddrive without being prompted for a password?
(Yes, I could mount the partitions by default making the necessary changes to /etc/fstab, but I want the additional security by only having root mount the partitions)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|