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
Run Code Online (Sandbox Code Playgroud)
这就是我今天所做的。
我想通过将输出ssh $SSHCRED "~/file-list.sh"直接发送到 rsync来做到这一点。那应该更快,而且我可以轻松地中止一个 rsync 操作。
但是我至少看到了一个问题:远程脚本生成了一个带有绝对路径的文件列表。为了让 rsync 正常工作,我想我需要在每个路径之前添加 SSH 凭据,如下所示:
user@host:/path/to/file1
user@host:/path/to/file2
user@host:/path/to/file3
Run Code Online (Sandbox Code Playgroud)
这可能吗?
生成文件列表并使用以下--files-from=FILE选项将它们交给 rsync :
rsync --your-options --files-from=filelist.txt user@host:/basedir targetdir
Run Code Online (Sandbox Code Playgroud)
这应该是很多快于rsync的调用为每一个文件。