rsync fails and can't connect to host - macos

I am running a rsync script that is very simple:
#!/bin/sh
rsync -avz --delete <path> user#hostname:<dest path>
I use it everyday and works fine, today it seems I can't run it and I am not sure why. Biggest change to my system I made is update Java.
The behavior is it just looks like it hangs, and if i let it run long enough I get:
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
I am able to rsync from my host to my machine but not vice versa.

The problem lies in my .bash_profile. I removed it and it seemed to work.
Odd thing is when I put it back it seems to still work

Related

rsync error (code 12) at io.c(226) [sender=3.1.3] on Mac OS

I'm trying to do a rsync network copy. I'm using homebrew's latest version of rsync. Both source and dest terminals show:
$ which rsync
/usr/local/bin/rsync
$ rsync --version
rsync version 3.1.3 protocol version 31
I can successfully scp a file from the src to dest with:
scp /Users/me/file.txt me#host.local:/Users/me/
However if I try the same with rsync:
rsync -avihX --progress --stats /Users/me/file.txt me#host.local:/Users/me/
I get the following error:
rsync: on remote machine: -vlogDtpXre.iLsfxC: unknown option
rsync error: syntax or usage error (code 1) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52.200.1/rsync/main.c(1337) [server=2.6.9]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.3]
I've seen other post here and most say it's either a bad file path or non-matching rsync versions on destination terminal, both of which I've rules out.
That "[server=2.6.9]" part of the message implies you are getting a version mismatch. I'm not sure exactly how it sends the rsync command to the remote end, but it doesn't always use the same PATH (and hence version) that you get interactively. Try adding --rsync-path=/usr/local/bin/rsync (or whatever the appropriate path for rsync v3.1.3 is on the remote computer) to force it to use the right version.

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

rsync not working for remote copy? [duplicate]

This question already has answers here:
rsync'ing files between two remote servers, get errors stating rsync command not found on remote server
(2 answers)
Closed 7 years ago.
I do the following command
rsync -a toCopy/Read_Files/ toCopy/Test
and it works. However when I try through remote access :
rsync -a toCopy/Read_Files/ root#192.168.155.148:/NightTest/
I got the following message
sh: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
Even though I followed instruction from this site
http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
section Copy a Directory from Local Server to a Remote Server
**See my answer to know what to do if you can't use rsync
I solved the problem using scp command instead, turned out one of the server didn't have rsync.
See this solution for scp command
https://serverfault.com/questions/264595/can-scp-copy-directories
For rsync, this may be useful if you have similar errors that I have but you have rsync on BOTH machine
rsync'ing files between two remote servers, get errors stating rsync command not found on remote server
The error was indeed pointing out to the fact that the remote machine did not have it :
sh: rsync: command not found
This error was only occurring when doing it remotely, indicating that the remote machine was not able to find this command.

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

Why is this rsync connection unexpectedly closed on Windows? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm trying to use rsync on Windows 7. I installed cwRsync and tried to connect to Ubuntu 9.04.
$ rsync -azC --force --more-options ./ user#server:/my/path/
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [receiver=3.0.5]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(610) [sender=3.0.8]
The trick for me was I had ssh conflict.
I have Git installed on my Windows path, which includes ssh. cwrsync also installs ssh.
The trick is to have make a batch file to set the correct paths:
rsync.bat
#echo off
SETLOCAL
SET CWRSYNCHOME=c:\commands\cwrsync
SET HOME=c:\Users\Petah\
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\bin;%PATH%
%~dp0\cwrsync\bin\rsync.exe %*
On Windows you can type where ssh to check if this is an issue. You will get something like this:
where ssh
C:\Program Files (x86)\Git\bin\ssh.exe
C:\Program Files\cwRsync\ssh.exe
I saw this when changing rsync versions. In the older version, it worked to say:
rsync -e 'ssh ...
when the rsync.exe and ssh.exe were in the same directory.
With the newer version, I had to specify the path:
rsync -e './ssh ...
and it worked.
I had this problem, but only when I tried to rsync from a Linux (RH) server to a Solaris server. My fix was to make sure rsync had the same path on both boxes, and that the ownership of rsync was the same.
On the linux box, rsync path was /usr/bin, on Solaris box it was /usr/local/bin. So, on the Solaris box I did ln -s /usr/local/bin/rsync /usr/bin/rsync.
I still had the same problem, and noticed ownership differences. On linux it was root:root, on solaris it was bin:bin. Changing solaris to root:root fixed it.
I had this error coming up between 2 Linux boxes. Easily solved by installing RSYNC on the remote box as well as the local one.
This error message probably means that you either mistyped the server name or forgot to start an ssh server at server. Make absolutely certain that an ssh server is running on the server at port 22, and that it's not firewalled. You can test that with ssh user#server.
i get the solution. i've using cygwin and this is the problem the rsync command for Windows work only in windows shell and works in the windows powershell.
A few times it has happened the same error between two linux boxes. and appears to be by incompatible versions of rsync

Resources