-1

I would like to use rsync to sync my files from remote to a local directory. Therefor I use StrictHostKeyChecking so that there's no need to enter a password.

Now I would like to only sync files older than 5 minutes. I thought to use

find /path/to/folder/ -type f -mmin +5

How can I integrate it into my remote procedure?

rsync -e "./ssh -i %syncclientkey% -o  'StrictHostKeyChecking no'" syncusr@%syncsrv:path/to/source path/to/destination
2

StrictHostKeyChecking has nothing to do with password-less authentication. It purpose is to issue a forward-confirmed reverse DNS to be sure that you are really connection to the intended server, and that no DNS-level hijacking is used to misdirect you to another server.

To use pubkey authentication, you had to follow these steps:

  1. create a new public / private keys using ssh-keygen
  2. copy the pubkey to the remote server using ssh-copy-id

Regarding the second part of your question, rsync by itself is not capable of time-based selection. You had to generate the filelist via find and pipe it to rsync.

For example: find /path/to/folder/ -type f -mmin +5 -print0 | rsync -files-from=- -from0 syncusr@%syncsrv:path/to/source path/to/destination

However, as rsync is extremely efficient in transfering only changed files/deltas, maybe you can entirely skip the file-selection step and simply synchronize the entire folder each 5 minutes. rsync will sync/transfer only the changed files (with a 5 minute interval, this means that only files changed in the last 5 minutes will be synchronized).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.