rsync delete option not working - unix

rsync is not deleting files from destination directory, though Adding/modifying files working properly .
When I am using below command, i am getting below error :
[MS-PROD-FTP]$rsync -rave --del "ssh -i $cert" $Local_Dir/*
$USER#$Remote_Hostname:$Remote_Dir**
rsync: Failed to exec --del: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(600) [sender=3.0.6]
Below command one executed with no error ,But files are not getting deleted in dest directory .
[MS-PROD-FTP]$rsync --del -rave "ssh -i $cert" $Local_Dir/*
$USER#$Remote_Hostname:$Remote_Dir**
sending incremental file list
sent 136 bytes received 12 bytes 296.00 bytes/sec
total size is 66 speedup is 0.45
Can someone help here ?

The issue was /* , correct command is :
rsync -rave --del "ssh -i $cert" $Local_Dir/ $USER#$Remote_Hostname:$Remote_Dir/
Thanks ,

Related

Rsync from local linux to remote windows server

I am trying to copy files from local Linux server to remote windows file server using rysnc and sshpass but getting error
code
rsync --rsh='/usr/bin/sshpass -p 'password' ssh -p 139 -o StrictHostKeyChecking=no -l user' /x/y/z/ user#x.x.x.x:/a/b/c/
output
ssh_exchange_identification: Connection closed by remote host
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
Can anyone help?

rsync command is giving error No such file or directory (2)

I am trying to transfer a file using in remote desktop which will create the directory tree as well in remote desktop as specified.I am using below command but its not working when directory is not present in remote server.
rsync -avzhe ssh --progress /root/BP/temp/temp.txt root#host2:/root/BP/temp2
Where /root/BP/temp/temp.txt is available in local but /root/BP/temp2 this path is not peresent in remote server.
I am getting below error :
rsync: change_dir#3 "/root/BP" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(625) [Receiver=3.0.9]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
If you need to move files to a non existent path on the remote server, you must either:
Model the path and file structure locally and sync a common "ancestor".
This is requires only 1 step
Create the missing directories locally and sync them first then sync the files.
This requires 2 steps
To use the OP's specific example of:
rsync -avzhe ssh --progress /root/BP/temp/temp.txt root#host2:/root/BP/temp2
You would instead do:
# assuming that /root already exists on the remote server
mkdir -p /root/BP/temp/or_wherever/BP/temp2
mv /root/BP/temp/temp.txt /root/BP/temp/or_wherever/BP/temp2
rsync -avzhe ssh --progress /root/BP/temp/or_wherever/BP root#host2:/root/
But if for some reason you cannot move the file in question, you must use the second option:
# assuming that /root already exists on the remote server
mkdir -p /root/BP/temp/or_wherever/BP/temp2
# Notice there is no `/` after the `or_wherever/BP` in the next command
rsync -avzhe ssh --progress /root/BP/temp/or_wherever/BP root#host2:/root/
rsync -avzhe ssh --progress /root/BP/temp/temp.txt root#host2:/root/BP/temp2/

Why do I get this error while running rsync?

I'm trying to transfer my file from localhost to server using rsync. But this is what happens
abc#abc_def:~$ rsync -v -e ssh textfile.txt
abc#123.45.67.890:/home/test
ssh: connect to host 123.45.67.890 port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]
abc#abc_def:~$
oops there was a mistake in the command just now i had cleared and it working now.
rsync -av -P -e 'ssh -p 1111' text.txt abc#123.45.67.890:/home/abc

Rsync fails when escaping parameters

I am currently testing rsync in order to synchronize some file between two servers.
When I espace the parameters of my command line with single quote, rsync seems to failed:
'rsync' '--recursive' '--verbose' '--archive' '--copy-dirlinks' '--rsh="ssh -i /path/to/my/key"' '--delete' '/path/to/my/source/directory' 'user#server:/path/to/my/destination/directory'
rsync: Failed to exec ssh -i /path/to/my/key: No such file or
directory (2) rsync error: error in IPC code (code 14) at pipe.c(85)
[sender=3.1.2] 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.2]
But when I do not escape the parameters, rsync works correctly:
rsync --recursive --verbose --archive --copy-dirlinks --rsh="ssh -i /path/to/my/key" --delete /path/to/my/source/directory user#server:/path/to/my/destination/directory
I am using the 3.1.2 version.
I am doing something wrong ?

Get current progress of rsync daemon

I am running rsync process as a daemon. Rsync tool does not accept --progress and --daemon options together. I thought to parse the /var/log/messages and rsyncd.log file, is it a correct approach ? Is there any other possibility to get the current progress of the synced data ?
Current usage of rsync -
rsync --daemon --config="/etc/rsyncd1.conf" --address=10.2.2.3
After adding --progress option
rsync -v --progress --daemon --config="/etc/rsyncd1.conf" --address=10.2.2.3
Starting rsync [10.2.2.3]: rsync: --progress: unknown option (in daemon mode)
(Type "rsync --daemon --help" for assistance with daemon mode.)
rsync error: syntax or usage error (code 1) at options.c(1005) [client=3.0.6]
[FAILED]
What about following workaround?
I've made a script, that calculates the whole rsync progress in Python. You could modify it to send needed info to syslog or whatever suits your needs and run it as daemon.

Resources