Perhaps you can use rsync as the recipient of find .
-a # preserve permissions and archive
-z # will compress for transmission
-v # is verbose
--dry-run # is for testing, it will show the result without doing anything. Remove it to do the real work
--remove-source-files # will delete the files after the transfer is successful
--files-from=- # will pickup the list of files to transfer from stdin.
-0 # to handle find output
-e ssh # to transfer encrypted, via the ssh protocol
Sorry my lateness in response. I had issues with connection.
Source Server: is the server where the files I want to copy reside
Destination Server: is the server where I try to send the command to transfer the files from Source Server to Destination Server.
So, I'm trying to send the command you suggest in the way below in Destination Server but I get the errors below:. What I'm doing wrong?
Thanks for the help.
find /path/ -mtime -1 -type f -printf %P\\0 | rsync -azv --dry-run --remove-source-files --files-from=- -0 /path/ -e ssh root@192.168.100.20:/destination/
find: �/path/': No such file or directory
root@1192.168.100.20's password:
building file list ...
rsync: change_dir "/path/" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at flist.c(2118) [sender=3.1.1]
/path/ was intended as an example; you have to substitute it for your own directory, the one you want to search from. Same goes with /destination/ , you have to substitute for the destination directory you want.
The files I want to transfer/copy from are in Server A (Source Server) and it has the addres 192.168.100.20
The Server B would be the destination server
In Server A, the files I want to copy are in path "/SourceFiles"
In Server B I have the destination folder "/DestinationServerB"
I'm trying to send the command from the destination Server (Server B) in the way below but I still get the error.
The assumption is that you are issuing the command from server A. Therefore the ip at root@ must be of server B and you are entering the ip of server A.
It is best if you always post the errors and warnings you are getting, even when it looks unimportant or does not make sense to you.
But I'd like to connect auntomatically via script to Server A (Source Server) from Server B (Destination Server) and extract the desired files. I want to avoid to set scripts in Source Server.
Is there a way to do this?
Source Server data:
user: root
password: xyzw
IP: 192.168.100.20
find /SourceFiles/ -mtime -1 -type f -printf %P\\0 | rsync -azv --dry-run --remove-source-files --files-from=- -0 /SourceFiles/ -e ssh root@192.168.100.20:/DestinationServerB/
DestinationServerB
find: �/SourceFiles': No such file or directory
root@192.168.100.20's password:
building file list ...
rsync: change_dir "/SourceFiles" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at flist.c(2118) [sender=3.1.1]