how can i debug these rsync errors - linux

I've been trying to get rsync working to keep track of files from a web server (linux) to my windows desktop.
Both the server and my machine has rsync installed. I am trying to pull files from the server down to my local machine, just the ones that have changed or update since I pushed them to the server as it's a file based CMS running.
If I run: rsync -avn -e "ssh -p [port]" [user]#[ip]:~/public_html/ ./ - So I am hoping that this will copy files from the /public_html/ folder so the current directory I am running from the command from.
The errors I get are:
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]
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [Receiver=3.2.7]
I've read that a server and localhost can have different versions and still run ok, and some people suggest directory issues but the directory exists. How can I debug this more?

Related

Run rsync via cron on Mac OS Catalina

There are many posts about this on the web but I have not found a working solution for my issue.
I'm on Mac OS Catalina. I have written a script to rsync a remote directory, via ssh, to my local computer:
#!/bin/bash
/usr/bin/rsync -arvzhe --delete 'ssh -i /Users/myusername/.ssh/id_rsa' user#XX.XXX.XX.XX:/home/storage/app/public /Users/myusername/public/
But it fails with the error:
Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54/rsync/io.c(453) [receiver=2.6.9]
The rsync call works fine when calling manually from the Terminal.
I do have a private key file in /Users/myusername/.ssh/id_rsa
Thanks.
You have to give your terminal app full disk access. (It will still have to obey Unix-level permissions after you do, but right now you are bumping into another layer of security that Mac OS has added.)
To fix, go to: System Preferences => Security and Privacy => Privacy, select "Full Disk Access" and check the "Terminal" box on the right.

Large SSH rsync backup script is failing for only 1 dir, the rest work - (code 255) at io.c(605) [Receiver=3.0.9]

First, thanks for clicking on this thread and considering stuff :) We have a large script that handles backups for 30+ servers. The system that the backup server is trying to rsync with is a server that takes files from multiple other servers and stores them in sep folders with different owners. Its a jailed SCP environment.
Anyways, I got this error on one of the directories after running my script and
can't figure out a good way to deal with it:
2017-03-09 02:34:06,594 - root - INFO - Command: '/usr/bin/rsync','-akh',
'--rsh=ssh -c arcfour -F /root/.ssh/dbconfig','--delete',
'--stats','--timeout=7200','--bwlimit=2500000',
'shen-prod#bck3a.domain.com:~/first/incoming/ ~/second/incoming/',
'/usr/local/shen/backups/shen-prod/mysql/2017-03-09'
2017-03-09 02:34:06,771 - root - WARNING - Permission denied, please try again.
2017-03-09 02:34:06,772 - root - WARNING - Permission denied, please try again.
2017-03-09 02:34:06,773 - root - WARNING - Permission denied (publickey,password).
2017-03-09 02:34:06,773 - root - WARNING - rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
2017-03-09 02:34:06,774 - root - INFO - added /usr/local/domain/backups/shen-prod/mysql/2017-03-09 to the progress file
2017-03-09 02:34:06,775 - root - WARNING - rsync error: unexplained error (code 255) at io.c(605) [Receiver=3.0.9]
So what makes this kindof weird for me is that the same script is able to properly sync a different folder on the same system. Example: above it is failing on /usr/local/shen/backups/shen-prod/mysql/2017-03-09. When the next part of the script runs, it will properly sync /usr/local/corn/backups/corn-prod/mysql/2017-03-09 on the same server. Both parts of the script are referencing the same SSH key file on the same server but it won't work for shen-prod.
I cannot remove everything from the hosts files and try to start over since there are so many systems using this script constantly throughout the day. Should I just send another ssh-copy-id to the server that is tryign to get backed up? I don't want to break the other backups that are working with that key.
Let me know what you guys think on this. Im getting to the point where im over-thinking everything and kindof freezing up. Thanks in advance for your consideration!
S
EDIT: Here are the 2 parts to the actual backup script. The "corn-prod" is working properly, "shen-prod" is not working. They are both on the same host, just in separate directories. The permissions on the directories are setup properly. Each user (corn-prod and shen-prod) are owners of the directory.
[corn-prod]
dest_dir=/usr/local/domain/archive/backups/corn-prod
user=corn-prod
host=bck3a.domain.com
rsync_options= --rsh=ssh -c arcfour -F /root/.ssh/dbackupconfig
sources=~/primary/incoming/ ~/secondary/incoming/
[shen-prod]
dest_dir=/usr/local/domain/archive/backups/shen-prod
user=shen-prod
host=bck3a.domain.com
rsync_options= --rsh=ssh -c arcfour -F /root/.ssh/dbackupconfig
sources=~/primary/incoming/ ~/secondary/incoming/
Thank you so much!!!

Encountering errors when rsync files to a NAS via ssh

Hi everyone on Stack Overflow,
I am attempting to rsync files from a specific folder of my CentOS 6.7 server to a EMS5 NAS 3000-SRL16. I tried the following code:
rsync -av -e ssh /bml/Data/ admin#IP address::BMLab
/bml/Data/ is the folder needs backing up, and I have a folder called BMLab in the NAS. The IP address of the NAS is typed in "IP address" above.
However, error messages showed up. I'm pasting them below:
rsync: server sent "Welcome to cliadm 1.0 build:$Revision: 173 $" rather than greeting
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
I don't have any previous experience regarding rsync, and I really have no idea of what's going on here, not to mention that how to solve it.
Any response is much appreciated.

rsync from linux to windows without smb mount

I would like to use rsync to mirror a git repo from a linux machine to several Windows servers. What I'm seeing online so far are solutions that require you mount the Windows side using samba. ideally I would like to avoid that because it would require managing several mounts, not to mention security concerns. I've verified that I can at least ssh onto my test server. I have cwRsync installed on the windows server. I try the following command, but rsync doesn't seem to like the space in the path to the rsync executable.
rsync -rlH --rsync-path="c:/Program\ Files/cwRsync/bin/rsync.exe" . Administrator#cool03-stage:d:/rsync_test/.
'c:/Program\' is not recognized as an internal or external command,
operable program or batch file.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
After adding C:\Program Files\cwRsync\bin to my PATH on the Windows server, I can run this:
rsync -rlH -e ssh . Administrator#cool03-stage:/cygdrive/d/rsync_test/.
Seems to work.

rsync ssh fails to connect

When trying to connect via rsync to download a file using the following command:
rsync -Pav http://some.domainname.com/file.tar.gz
The following error is given to me
ssh: Could not resolve hostname http: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(605) [Receiver=3.0.9]
If i try and download the same file using the ftp commands instead it works fine. If i try and use the rsync command from a pc on another network instead this also works fine, so it seems to be something environmental.
The customers client pc sits behind a proxy server, but all the proxy address details have been added to the system, and i'm able to browse, ftp, and ssh onto a test server without any issues. Is there anything that may be blocking rsync from running?
You are mixing curl/wget and rsync.
wget http://some.domainname.com/file.tar.gz
or
rsync a_user#some.domainename.com:/path/to/webdir/file.tar.gz /local/dest/dir

Resources