Transferring from Windows to Linux with rsync - windows

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.

Related

Rsync error: The source and destination cannot both be remote

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

Copy folder from an http source to a local directory

I am trying to copy a folder from an http source using the following statement:
FileUtils.cp_r 'http://else.repository.labs/static/lit/MDMInternalTools/', 'c:\Users\Public\Desktop\'
However I get this error:
EINVAL: Invalid argument - https://else.repository.labs/static/lit/MDMInternalTools/
If that's a folder on a server that you have access to via ssh, then you can use scp to copy individual files, or a folder with all subfolders/files, using the -r option. The command will be something like
scp -r username#http://else.repository.labs:/path/to/rails/public/static/lit/MDMInternalTools c:\Users\Public\Desktop
This is assuming you can use scp. It looks like you're in windows, you'll need a decent command-line shell where you can install ssh.
https://en.wikipedia.org/wiki/Secure_copy
You can check if the server supports webdav, have an ftp or an ssh access.
Otherwise your only choice could be to use wget to get a local mirror:
wget -mk http://else.repository.labs/static/lit/MDMInternalTools/

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/

rsyncing using cygwin's rsync from the Windows Command Prompt

I am pushing a local file to a folder in a remote location using cygwin's rsync from the Windows Command Prompt.
The below command
D:\My Folder>C:/cygwin/bin/rsync.exe -avh data.csv ec2-user#someserver.com::~"overhere/"
returns the error, "failed to connect to someserver.com : connection timed out"
When I try the following command to place the file in the remote location root folder,
D:\My Folder>C:/cygwin/bin/rsync.exe -avh data.csv ec2-user#someserver.com~
it says "sending incremental file list" but I am not able to find the file in the root folder in the remote location.
What am I doing wrong?
The timeout most likely occurs because there is no rsync daemon running on the server known as someserver.com.
Using :: after the remote host name will cause rsync to try to connect to the rsync daemon running on that machine. If you use : instead, rsync will attempt a shell access to copy your data.
Your second call to rsync.exe succeeds because rsync.exe -avh data.csv c2-user#someserver.com~ creates a copy of data.csv in your current working directory named ec2-user#someserver.com~.
If you use shell access, you can directly provide the path after the :, if using the rsync daemon, you have to provide the module name as configured in /etc/rsyncd.conf on the server after the ::. So in your case it is either ec2-user#someserver.com:~/overhere/ for shell access or ec2-user#someserver.com::MODULE for the daemon.
But as I suspect that you have no rsync daemon running on the remote machine, you'd have to install and configure it first for the second version to work. The first version will do through normal SSH access.
So as a first attempt you can try: D:\My Folder>C:/cygwin/bin/rsync.exe -avh data.csv ec2-user#someserver.com:overhere/
This will create a folder named overhere in the ec2-user's home directory on someserver.com if it doesn't already exist and copy the local data.csv into that directory.

Moving a folder from Desktop to the server?

I have a folder in my Desktop. I want to copy it to my server in Terminal.
I tried this unsuccessfully
[~/bin]# cp -r /Users/Sam/Desktop/tig-0.14.1 ~/bin/
cp: cannot stat `/Users/Sam/Desktop/tig-0.14.1': No such file or directory
[edit]
I run the command in my server. The problem seems to be in the fact that "/Users/Sam/Desktop/tig-0.14.1" is a folder in my Mac, not in my server.
Perhaps, I cannot move the folder so simply to my server because my server do not know where my folder locates.
I have always moved the folder by GUI. Is the same possible also just in terminal?
From the server:
scp -r username#A.B.C.D:~/Desktop/tig-0.14.1/ ~/bin/
username is your shortname on your local mac.
A.B.C.D is the IP address of your local mac as seen by the server.
You will be prompted for your password.
Or if you wanted to push from your local client:
scp -r ~/Desktop/tig-0.14.1/ serveruser#W.X.Y.Z:~/bin/
serveruser is the user on the server whose ~/bin you want to copy into.
W.X.Y.Z is the IP address of the server as seen by your client.
You will be prompted to enter serveruser's password.
scp is part of ssh. See 'man scp' (from the terminal) for more info.
From your Mac (not the server):
# scp -r ~/Desktop/tig-0.14.1 myUsername#myServerName:~/bin
replace myUsername and myServerName appropriately.
cp is not the correct command. Try scp instead; it has similar use and you can use it like this: (see the manual for reference)
from linux client:
scp user1#host1://Users/Sam/Desktop/tig-0.14.1 ~/bin/
if you use a windows client you can use winscp to do this in "drag&drop" style
cp: cannot stat/Users/Sam/Desktop/tig-0.14.1': No such file or directory`
That's the problem, alright: the file you're trying to copy is not where you thought, or not named what you typed. As suggested in comments you can try using tab completion at the prompt to make sure you have everything correct:
# cp /Users/Sam/Desk<TAB>
# cp /Users/Sam/Desktop/tig<TAB>
# cp /Users/Sam/Desktop/tig-0.14.1.tar.gz
Note that tig-0.14.1.tar.gz is probably the actual file name, as found in the wild...

Resources