如何使用 `–files-from` 选项来下载一个文件列表?

huangapple go评论49阅读模式
英文:

How to use `--files-from` `rsync` option to download a list of files?

问题

我正在使用以下命令从远程下载文件夹,使用rsync:

sshpass -p "my_pwd" rsync -av --partial --progress
<usr>@<remote>:/home/remote/folder /home/local/folder/

现在,我想下载文件列表,而不是整个文件夹:我看到可以使用 --files-from 来实现,但不清楚如何使用此选项。

我尝试创建文件,并指定文件,例如:

/home/remote/folder/file1
/home/remote/folder/file2

我还尝试在远程路径前添加:

<usr>@<remote>:/home/remote/folder/file1
<usr>@<remote>:/home/remote/folder/file2

然后分别使用以下命令启动:

sshpass -p "my_pwd" rsync -av --partial --progress --recursive
<usr>@<remote> --files-from=files.txt /home/local/folder/

或者

sshpass -p "my_pwd" rsync -av --partial --progress --recursive
--files-from=files.txt /home/local/folder/

但都没有成功。

有人可以帮助我吗?

英文:

I'm using the following command to download a folder from remote using rsync:

sshpass -p &quot;my_pwd&quot; rsync -av --partial --progress  
    &lt;usr&gt;@&lt;remote&gt;:/home/remote/folder /home/local/folder/

Now, instead of downloading the entire file I want to download a list of files: I've seen I can do this using the --files-from but it's not clear how to use this option.

I've tried to create the file by specifying the files, for example:

/home/remote/folder/file1
/home/remote/folder/file2

and I've also tried to preappend the remote:

 &lt;usr&gt;@&lt;remote&gt;:/home/remote/folder/file1
 &lt;usr&gt;@&lt;remote&gt;:/home/remote/folder/file2

and launch respectively with the command

sshpass -p &quot;my_pwd&quot; rsync -av --partial --progress --recursive 
    &lt;usr&gt;@&lt;remote&gt; --files-from=files.txt /home/local/folder/

or

sshpass -p &quot;my_pwd&quot; rsync -av --partial --progress --recursive 
    --files-from=files.txt /home/local/folder/ 

but neither worked.

Can someone help me out here?

答案1

得分: 1

好的,我找到了指令,我会将问题保留,以便有人需要时可以使用,而不是删除它

    sshpass -p "my_pwd" rsync -av --partial --progress --recursive 
        <usr>@<remote>:/home/remote/folder --files-from=files.txt /home/local/folder/ 

拥有以下文件

    file1
    file2
英文:

Ok, I've found the command, I will leave the question in case someone need instead of deleting it

sshpass -p &quot;my_pwd&quot; rsync -av --partial --progress --recursive 
    &lt;usr&gt;@&lt;remote&gt;:/home/remote/folder --files-from=files.txt /home/local/folder/ 

having the following file

file1
file2

huangapple
  • 本文由 发表于 2023年7月24日 16:20:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76752600.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定