rsync using sudo via remote shell

Wayne Davison wayned at
Mon Aug 30 18:24:19 GMT 2004

On Mon, Aug 30, 2004 at 08:08:09PM +0200, Achim St?bler wrote:
> rsync -avz -e "ssh -i /home/backup/.ssh/id_dsa" backup at server:/ 
> /backup/server/
> Unfortunately I can't figure out how to tell rsync to execute its remote 
> instance via sudo.

You can do this via the --rsync-path option:

rsync -avz -e "ssh -i /home/backup/.ssh/id_dsa" --rsync-path='sudo rsync' backup at server:/ /backup/server/

You'll also want to make sure that sudo doesn't prompt for a password,
so you could start with a simpler command right before the rsync:

ssh -i /home/backup/.ssh/id_dsa -l backup server sudo date


More information about the rsync mailing list