Rsync over ssh, or something else?

10

3

I've been trying to use rsync on OSX to Linux or Unix box over which I don't have much control. I've been doing something like this

rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/ 

Error returned is:

bash: rsync: command not found rsync: connection unexpectedly closed (0 bytes received so far) [receiver] rsync error: remote command not found (code 127) at /SourceCache/rsync/rsync-37.3/rsync/io.c(452) [receiver=2.6.9]

However, after reading the docs I'm beginning to think that I would actually need to install an rsync daemon on the remote host.

  1. Must I install an rsync server on the remote host?
  2. Free alternatives -- GUI or non-GUI -- which do not require installing anything on the remote host?

Thanks!

Dan Rosenstark

Posted 2010-02-07T13:10:27.087

Reputation: 5 718

1What are the exact problems are you having with your current command? – fideli – 2010-02-07T14:11:37.307

@fideli, sorry, forgot about that. Editing question now – Dan Rosenstark – 2010-02-07T14:16:29.173

1Thanks for this question, but can you tag it rsync please? – Andrew Grimm – 2010-10-17T03:54:25.507

Answers

21

You need an rsync command on the server, but you don't need to run a daemon.

Get an rsync binary that works on the server, put it somewhere in your home, and add this flag to your command line: --rsync-path=/home/user/path/to/rsync .

If you don't want to copy rsync to the servers, you can use scp, or sshfs.

sshfs user@host ~/sync/user-host
rsync -av ~/local-dir ~/sync/user-host/remote-dir

In that case rsync will run completely locally, but the changes will be propagated to the server.

Tobu

Posted 2010-02-07T13:10:27.087

Reputation: 2 584

I like that solution a lot, particularly because the server is a cheap hosting plan on GoDaddy and I doubt I'll be able to run rsync on the server. +1 for now! – Dan Rosenstark – 2010-02-07T15:11:12.673

What's the easiest route to go for install of sshfs on OSX? MacFuse or is there something easier? – Dan Rosenstark – 2010-02-07T15:24:35.707

MacFuse + (MacFusion or sshfs-static-leopard), I think (I'm not an OSX user) – Tobu – 2010-02-07T15:37:29.893

Yes MacFuse does it. Just that the download page for the sshfs binary gives you the binary with a .gz extension. So you have to rename it instead of gunzip'ing it. Annoying but okay now! Thanks – Dan Rosenstark – 2010-02-07T16:32:37.657

6

You need to have rsync on the remote host -- not necessarily an rsync server (which, I believe, won't handle the ssl connection anyway), but rsync on the local box needs to talk to an rsync on the remote box. You're using ssh to link the two.

Assuming rsync does exist on the remote box, it is not in the default search path for your ssh logged in shell. Depending on your preferences and permissions on the remote box, you can try

  • using the --rsync-path= option
  • changing the default PATH for your remote ssh shell
  • adding an alias for rsync in the remote ssh shell
  • changing the executed remote command to the absolute path to rsync

or something similar. If rsync as an executable (vice server) does not exist on the remote host, it would have to be added.

mpez0

Posted 2010-02-07T13:10:27.087

Reputation: 2 578

This was helpful, so +1, but I'm wondering how to specify the starting directory for rsync on the Windows side if I'm running it from Mac to PC like this: https://superuser.com/questions/1462861/diff-directory-contents-from-mac-to-pc-on-same-network#comment2206261_1462865

– Ryan – 2019-07-23T00:28:06.230

1

There is not much point using rsync without running an rsync daemon on the remote host, in spite of the creative sshfs solution proposed above. The whole idea of efficiency in rsync is to have the two instances compare their local copies of the dataset by calcuating checksums locally, comparing them over the network, and only transmitting the actual data for those parts of those files which actually differ.

If you use sshfs or any network mount, it's only hiding the fact that it has to copy the entire dataset across the network from the remote host in order to calculate the checksums locally, and then transmit the differences on top of that. It would be quicker and cheaper to delete everything locally and 'scp -r' the lot.

huge

Posted 2010-02-07T13:10:27.087

Reputation: 11

3Not exactly, because rsync checks whether files are modified by size and timestamp, and that's still a lot more efficient than scp'ing all files. But indeed, the rsync incremental update mechanism within files doesn't make sense over sshfs. – Jaap Eldering – 2011-07-14T12:52:10.377

0

Try SCP. As you've already got ssh access you don't need to install anything else on the remote host :)

To copy files from the remote host to the localhost use :

# scp -R remoteuser@remotehost:/remote/dir /this/dir/ 

Or copy files from the localhost to the remote host with :

# scp -R /this/dir remoteuser@remotehost:/remote/dir 

lyarwood

Posted 2010-02-07T13:10:27.087

Reputation: 1 804

1Thanks Lee, SCP is great but it doesn't do "sync" right? – Dan Rosenstark – 2010-02-07T15:07:58.593

1it must be a small "r": scp -r – 0x4a6f4672 – 2013-01-23T10:43:00.200