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
Related
I'm trying to rsync a large directory of around 200 GB from a server to my local external hard drive. I can ssh onto the server and see the directory fine. I can also cd into the external hard drive fine. When I try and rsync the file across, I don't get an error, but the last line of the rsync output is 'total size is 0 speedup is 0.00', and there are no files in the destination directory.
Here's how I ssh onto the server successfully:
ssh skgtmdf#live.rd.ucl.ac.uk
Here's my rsync command:
rsync -avrt -progress -e "ssh skgtmdf#live.rd.ucl.ac.uk:/mnt/gpfs/live/rd01__/ritd-ag-project-rd012x-smmca23/" "/Volumes/DUAL DRIVE/ONP/2022.08.10_results/"
And here's the rsync output:
sending incremental file list
drwxrwxrwx 65,536 2022/08/10 21:32:06 .
sent 57 bytes received 64 bytes 242.00 bytes/sec
total size is 0 speedup is 0.00
What am I doing wrong?
The way you have it quoted, the source path is part of the remote shell option (-e value) rather than a separate argument as it should be.
rsync -avrt -progress -e "ssh skgtmdf#live.rd.ucl.ac.uk:/mnt/gpfs/live/rd01__/ritd-ag-project-rd012x-smmca23/" "/Volumes/DUAL DRIVE/ONP/2022.08.10_results/"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is all part of the `-e` option value
This means rsync doesn't see that as a sync source at all, but just part of the command it'll use to connect to the remote system. I'm not sure why this doesn't lead to an error. In any case, the fix is simple: don't include ssh with the source path.
As I noticed later (see comments) the --progress option needs a double-dash or it'll be wildly misparsed. Fixing both of these things gives:
rsync -avrt --progress -e ssh "skgtmdf#live.rd.ucl.ac.uk:/mnt/gpfs/live/rd01__/ritd-ag-project-rd012x-smmca23/" "/Volumes/DUAL DRIVE/ONP/2022.08.10_results/"
In fact, since ssh is the default command for making a remote connection, you can leave off -e ssh entirely:
rsync -avrt --progress "skgtmdf#live.rd.ucl.ac.uk:/mnt/gpfs/live/rd01__/ritd-ag-project-rd012x-smmca23/" "/Volumes/DUAL DRIVE/ONP/2022.08.10_results/"
rsync -azve ssh user#host:/src/ target/
Normally, you don't need to wrap -e flag with ". It's probably messing the connection string
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.
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
I need to write a bash command line that uses ssh to connect to "first_machine" and from here run rsync to another machine remoteuser#10.2.2.150.
This is my code:
first_machine = user#192.16.58.12
cmd="ssh #{first_machine} \"rsync -e\"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" --archive -H /home/user/aaaaa remoteuser#10.2.2.150:/home/remoteuser/\" "
exit_status = system("#{cmd}")
I tested the ssh command and also the rsync separately. They work fine, so I can do ssh from the machine where I run the Ruby script and:
rsync -e"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --archive -H /home/user/aaaaa remoteuser#10.2.2.150:/home/remoteuser/
works well when launched in the #{first_machine} -> folder is copied.
Instead, when I run my code through the Ruby script I receive the error:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]
This error does not occur if I run the command separately.
First, fix the user problems pointed out by the Tin Man in the other answer. Do you have public key authentication set up between first_machine and the user running the ruby script?
Then, look at your quoting and you'll see that the command you're passing to ssh consists only of rsync -e. Maybe try this:
first_machine = 'user#192.16.58.12'
cmd="ssh #{first_machine} \"rsync -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --archive -H /home/user/aaaaa remoteuser#10.2.2.150:/home/remoteuser/\" "
exit_status = system(cmd)
Disclaimer: I've never used Ruby before, but a 2 minute glance at some tutorial sites made it clear you've got syntax errors in your sample code.
Is there a reason not to do this as a bash script?
When you "run the command separately", you're running it as a user with known permissions and an environment that's set.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
is your hint that the permissions aren't right for the account when it logs in from the code. This isn't a Ruby problem, it's a result of not using the right account, or not setting up the environment; It's outside Ruby.
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