Rsync error: The source and destination cannot both be remote - macos

I am able to Rsync files from my remote server to my local machine.
rsync -av [remote-server]:web/wp-content/uploads
Users/[username]/Documents/workprojects/iis-tech/web/wp-content
Thats fine, but when I try to rsync from my local machine to my remote server I get the following error:
The source and destination cannot both be remote.
rsync error: syntax or usage error
The command I am running is as follows:
rsync -av /Users/[username]/Documents/workprojects/[project-folder]/web/wp-content/themes/reactify/js/build/
[remote-server]:web/wp-content/themes/reactify/js/build
I separated the command for readability.
I am using Platform.sh as the host if that makes a difference, but I don't think that is the issue.
The reason why I am confused is because my coworkers are able to run the same command successfully.
Any help is appreciated!

Use rsync -av /cygdrive/c.... /cygdrive/d/....
That is, replace C: with /cygdrive/c

Related

How to copy files from one machine to another machine

I want to copy /home/cmind012/m.sh from one system to another system (both system Linux) using shell script.
Command $
scp /home/cmind012/m.sh cmind013:/home/cmind013/tanu
getting message
ssh: cmind013: Name or service not known
lost connection
It seems that cmind013 is not being resolved, I would try using first
nslookup cming013
and see what why donesn't it resolve.
It seems that you are missing the IP Address/Domain of the remote host. The format should be user#host:[directory]
You could do the following:
scp -r [directory/files] [remote host]:[destination directory]
ex: scp -r /var/www/html/* root#192.168.1.0:/var/www/html/
Try the following command:
scp /home/cmind012/m.sh denil#172.22.192.105:/home/denil/

Rsync command fails in Cygwin

I've been struggling with this for a day now and can't figure out what I'm doing, I haven't been able to find anything with Google some hopefully someone here can help:
I'm trying to use rsync to sync a folder between my Ubuntu server and my window's machine using Cygwin. I issue:
$ rsync -av -e "ssh 10.0.0.28 -pxxxx -i /home/my_user/.ssh/id_rsa -l my_user" my_user#10.0.0.28:/backup/folder/ /backup/folder/
bash: 10.0.0.28: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [Receiver=3.1.1]
If I just extract the code in the double quotes and run it it correctly opens the ssh connection. Does anyone know what is going on here?
You probably should not specify an address and login in ssh command. Rsync will do it for you. Try
rsync -av -e "ssh -pxxxx -i /home/my_user/.ssh/id_rsa" my_user#10.0.0.28:/backup/folder/ /backup/folder

rsync to move file from local to remote machine and execute command on remote machine

I have one file in my local Linux machine and I want to move that one to remote machine and then execute one command on remote machine to restart the service. The issue is after moving the file the remote connection get closed. I have used the following command:
rsync --remove-source-files -av -e ssh -t /home/testdata.txt root#vdstvmaster:/home/; service restart
If I execute the above command file is successfully moved to remote machine. But the second command (service restart) is not executed on remote machine.
rsync can use a remote shell to perform the copy operation. But it is not meant as a "general-purpose" remote shell application. Just invoke the second command over SSH locally after the rsync command like this:
rsync --remove-source-files -av -e ssh -t /home/testdata.txt root#vdstvmaster:/home/
ssh root#vdstvmaster service restart
BTW some people may consider remotely logging into another machine as root bad security.

sudo rsync locally lack of permission

What is the command to LOCALLY Rsync a bunch of folders that by default rsync doesnt have the necessary rights for. (in the terminal i have to sudo rsync for that matter). But in a shell script it works a little different.
I have been reading about
rsync --rsh-path="sudo rsync" -aq...
and another said:
rsync --rsh="ssh me#Mac sudo" -aq...
And all the others are talking about remote rsyncing.
but none of local ones seem to work.
Someone can shine a light on this?
cheerz!
if you work locally just run rsync with escalated rights and leave out all the other options like so:
sudo rsync -avP source target
you can replace -avP of course to fit your needs about what information gets transferred and what output is generated.

Transferring from Windows to Linux with rsync

noob here,
I'm trying to transfer a file using rsync from windows to linux.
I have this code, but I'm getting an error
rsync -avz -e ssh C:\users\file.txt root#123.45.67.89:/var/dir
I get this error The source and destination cannot be both remote
And if I try
rsync -avz -e ssh /c/users/file.txt root#123.45.67.89:/var/dir
I get, No such file or directory
So, I think the problem is with the path of the file on the windows.. I've heard about cygwin but haven't really tried it
What can I do to get the path to work?
If you're using CygWin to rsync from the Windows box, the local file you want is almost certainly:
/cygdrive/c/users/file.txt
rather then:
/c/users/file.txt
Writing the right rsyncd.conf is a little bit complicated.
I get the error message
#ERROR: chdir failed rsync error: error starting client-server
protocol (code 5) at main.c(1296) [receiver=2.6.8]
and
2012/06/10 14:59:43 [9252] rsync: chdir /cygdrive/d failed : No such
file or directory (2)
Because I miss the "use chroot = false" directive in my rsyncd.conf
Here is an example of rsyncd.conf:
log file = c:/rsync.log
auth users = backup
secrets file = /cygdrive/c/Program Files/RSync/rsyncd.secrets
[backup]
comment = Backup this host
path = /cygdrive/d
use chroot = false
strict modes = false
read only = false
transfer logging = yes
hosts allow = 192.168.2.252
Be sure the rsync.log file is created/changed after restart service, if it's not done, you have some error in your rsyncd.conf file and the rsync does'nt use them but no error or info is showed at all!
And so, the format of rsyncd.secrets file, is:
backup:<password>
In the wsl2 env, use the rsync command indirectly.

Resources