Ssh – rsync file list over ssh generated by remote script


for f in `ssh $SSHCRED "~/"`
  rsync --progress --times --partial --append --rsh=ssh -r -h --remove-sent-files $SSHCRED:$f $OUTDIR

This is what I do today.

I'd like to instead do this by sending the output from ssh $SSHCRED "~/" directly to rsync. That should be faster, and I can easily abort just one rsync operation.

But I see at least one problem with this: The remote script generates a list of files with absolute paths. For rsync to work, I think I need to prepend the SSH credentials before every path, like this:


Is this possible?

Best Answer

Generate a list of files and hand them over to rsync with the --files-from=FILE option:

rsync --your-options --files-from=filelist.txt user@host:/basedir targetdir

This should be much faster than calling rsync for every single file.