Ssh – rsync file list over ssh generated by remote script

filesrsyncssh

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

This is what I do today.

I'd like to instead do this by sending the output from ssh $SSHCRED "~/file-list.sh" 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:

user@host:/path/to/file1
user@host:/path/to/file2
user@host:/path/to/file3

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.