Failed to execute rsync between my server and my Mac

I have a server that stores data from Mac A and Mac B.

I use rsync to update files between my Macs.

I run the following code unsuccessfully

#!/bin/zsh # to copy files from my server to my folder rsync -Pav $Masi:~/private/ ~/Dropbox/Courses/math/ # to copy files from my folder to my server rsync -Pav ~/Dropbox/Courses/math $Masi:~/private/ 

The following error message appears

 ssh: connect to host port 22: Connection refused rsync: connection unexpectedly closed (0 bytes received so far) [receiver] rsync error: unexplained error (code 255) at io.c(600) [receiver=3.0.5] ssh: connect to host port 22: Connection refused rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(600) [sender=3.0.5] 

I have ssh keys, so the connection should work, since I can use scp without any problems.

How can you use rsync between my server and one of my Mac computers?

+4
source share
3 answers

I often did this. Just ran a test, some tips.

  • Record the entire @host user template
  • Start ssh connection without rsync first, you may need to confirm your fingerprint first
  • You donโ€™t seem to pass the flag to protect extended attributes, this can cause files to crash on OS X. If you donโ€™t need resource plugs, you are fine, but most of the time they need you.

My test case:

 $ rsync -Pav ~/Desktop/ me@remote.example.com :~/rsyc-test 

In this case, all the files in ~ / Desktop were copied to the remote host in my home directory. Since the rsyc-test directory did not exist, it was created for me. I had .app on my desktop, it did it, surprisingly, it works. Even some .webloc files did this and seemed to work, although I don't trust him.

I would strongly suggest adding -E to the flag

  -E, --extended-attributes Apple specific option to copy extended attributes, resource forks, and ACLs. Requires at least Mac OS X 10.4 or suitably patched rsync. 

I launched a new test, moved the Interarchy bookmark to my desktop, I know that this is a break if they are copied without a resource plug. Running without -E compared to -E, there is a difference of 152 bytes in xfered data. The first file on the remote computer did not work, the second transferred file worked.

I cannot but notice that in your example one of your paths is ~ / Dropbox, so all this may not matter, since the DropBox application does not support resource widgets at all, although I heard that there are plans for the future.

You also do not send the -delete flag if your final destination is a mirror of your data, you do not receive this if your final destination is backups that are constantly growing, preserving everything that has ever been in the source, the disadvantage of -delete is good .

Other notes:
You can exclude these stupid .DS_Store files --exclude '.DS_Store'

You can also set rsync to be a true mirror, so you wonโ€™t need to run your other command, see the manual page for details.

My last working command to drag the desktop of my laptop to a remote computer is:

 $ rsync -PEav --delete --exclude '.DS_Store' ~/Desktop/ me@remote.example.com :~/rsycn-test 
+3
source

Tick โ€‹โ€‹"$ Masi". Is this the host name you are trying to reach?

Try the following command to debug it:

 rsync -e 'ssh -v' -Pav $Masi:~/private/ ~/Dropbox/Courses/math/ 
+1
source

Connection rejection usually occurs when a connection problem occurs on a remote computer (such as a firewall).

In your case, the problem is that the $Masi variable is empty. If it is not a variable, use Masi .

According to this error:

ssh: connect to host port 22: Connection refused

Note the double space above after the word host .

the host connection message does not indicate the host, so you are trying to connect to empty hosts. So it sounds like a typo in the host name.

+1
source

All Articles