RSYNC 从远程到本地不包括文件夹

Rob*_*Rob 2 localization rsync remote copy

如何从远程服务器下载到本地不包括文件夹或文件?

我用过这样的东西,但排除不起作用......

rsync -avr -P -e ssh --exclude=/path/to/exclude/* user@ipaddress:/home/path/to/copy /home/user/www
Run Code Online (Sandbox Code Playgroud)

建议?

Dmi*_*rov 5

这里的问题很可能出exclude在 rsync 过滤器中的路径上。

rsync 文件列表中使用的路径是对于 SOURCE 路径的。

也就是说,如果您的目录结构是

 /home/path/to/copy
                | files_to_copy
                     | file1
                     \ file2
                \ files_to_exclude
                     | file3
                     \ file4
Run Code Online (Sandbox Code Playgroud)

然后如果你发出命令

rsync -avr -e ssh user@host:/home/path/to/copy \
                 /home/user/www --exclude='files_to_exclude/*'
Run Code Online (Sandbox Code Playgroud)

您将在副本中获得以下结构

 /home/user/www
             | files_to_copy
                  | file1
                  \ file2
             \ files_to_exclude
Run Code Online (Sandbox Code Playgroud)

如果您不想files_to_exclude在副本中包含该目录,您可以使用以下命令:

rsync -avr -e ssh user@host:/home/path/to/copy \
                 /home/user/www --exclude='files_to_exclude'
Run Code Online (Sandbox Code Playgroud)