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?