I'm looking to create a script that logs into a machine and pulls back files to a NAS server. The files will be put into a compressed file as it downloads.
Because the script will be looking to download files with varying owners and permissions, it will need to run as root to make sure it captures everything in the home directory.
I have edited my visudo file to allow the backup user to sudo tar without a password. But there is something stopping the command from running successfully:
backup ALL=NOPASSWD: /usr/tar
Command ran from the NAS:
ssh -t [email protected] "sudo tar -zcf - /home/" > /var/backup/server1.tar.gz
Any help would be great, thanks
Update: It would of been good to know why I was down voted for this question.
I double checked running sudo tar on the machine with out SSH and indeed wasn't working (thanks @Fredi).
I then ran visudo again and moved the following to bottom of config, as this apparently makes the setting take precedence.
I was then able to SSH without the -t and run
sudo tar
.