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

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

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

问题

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

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

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

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

  1. /home/remote/folder/file1
  2. /home/remote/folder/file2

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

  1. <usr>@<remote>:/home/remote/folder/file1
  2. <usr>@<remote>:/home/remote/folder/file2

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

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

或者

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

但都没有成功。

有人可以帮助我吗?

英文:

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

  1. sshpass -p &quot;my_pwd&quot; rsync -av --partial --progress
  2. &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:

  1. /home/remote/folder/file1
  2. /home/remote/folder/file2

and I've also tried to preappend the remote:

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

and launch respectively with the command

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

or

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

but neither worked.

Can someone help me out here?

答案1

得分: 1

  1. 好的,我找到了指令,我会将问题保留,以便有人需要时可以使用,而不是删除它
  2. sshpass -p "my_pwd" rsync -av --partial --progress --recursive
  3. <usr>@<remote>:/home/remote/folder --files-from=files.txt /home/local/folder/
  4. 拥有以下文件
  5. file1
  6. file2
英文:

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

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

having the following file

  1. file1
  2. 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:

确定