2

I want to disable the requirement of sudo or running as root for a bash script that does backups with tar.

I added this line to my sudoers file

username ALL=NOPASSWD: /bin/tar

However after I added that it still shows permissions denied when I run this backup command

/bin/tar -cvpzf /root/sysBackup/backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /

These are the errors

/bin/tar: Removing leading `/' from member names                                                                                                          
tar (child): /root/sysBackup/backup.tar.gz: Cannot open: Permission denied                                                                                
tar (child): Error is not recoverable: exiting now        

What am I doing wrong?

1
  • 2
    You still need to run it as root, are you typing sudo first?
    – Sirch
    May 2, 2012 at 16:32

1 Answer 1

5

You still need to start your tar command via sudo inside your bash script:

sudo /bin/tar -cvpzf /root/sysBackup/backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .