ratnaprasad123
asked on
Need a script for for SFTP
Hi ,
I am looking for a shell script on linux for copying(SFTP) a file from remote system under a directory . When we run the scripts next time it should only copy (SFTP) new created files only .
Any examples would be appreciated .
Regards
I am looking for a shell script on linux for copying(SFTP) a file from remote system under a directory . When we run the scripts next time it should only copy (SFTP) new created files only .
Any examples would be appreciated .
Regards
ASKER
well, purpose of copying files is not for backup, after copying, a script will process the files and delete from the foleder.
if i use rsync it will again copy all the files.
if i use rsync it will again copy all the files.
There's always loads of ways to do things......and some methods are more complex than others. As it stands, I can put together a fairly complex script to do just what you require....but I'm sure that there are easier ways of doing it! If there is some pattern in the file names, then scp would do the job just as well:
scp root@server.ip.net:/home/m ylogs/*Jan 2005.log .
for example would copy all of the logs for Jan2005 into the local folder for processing.
If this approach isn't of use, then you need to give more information about what is happening in order to get a sensible solution.
HTH:)
scp root@server.ip.net:/home/m
for example would copy all of the logs for Jan2005 into the local folder for processing.
If this approach isn't of use, then you need to give more information about what is happening in order to get a sensible solution.
HTH:)
ASKER
we don't have particular file name pattern, the script has to check what is the last file, it has successfully down loaded(using time stamp or file name), if there are new files after the last file(time stamp) , it has to be down loaded, the last file down loaded should get updated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your comments i have recieved some good inputs from you.
Example:
rsync -Cavz -e ssh root@server.ip.net:/home /my/backup/dir/ | tee -a result.log
BAsically, this backs up all changed files from server.ip.net /home directory to a local backup directory, and records info in a result.log file
All you need then is the sshd running on the target.
HTH:)