May 31, 2017

[HDGEM] How to copy files to remote server with sudo

With SCP, you have to do in two steps, however, you can do it in one with rsync as follows:
rsync --rsync-path="sudo rsync" <LOCALFILE> [email protected]:/root  
Note: This does require NOPASSWD sudo.
use --rsync-path option to make rsync run with sudo.
The following command correctly creates all the directories and syncs the files as expected.
rsync -rvR --rsync-path="mkdir -p /srv/backupdir/Linux/sync/ && rsync" <LOCALFILE> [email protected]:/root

Posted By Blogger to HDGEM at 5/31/2017 06:54:00 AM
Post a Comment

Featured Post

Trading volumes of most major cryptocurrencies across leading exchanges remain low overall

Bitcoin's daily trading volume has been relatively low