从远程到本地的RSYNC排除文件夹

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

我用过这样的东西,但排除不工作…

rsync -avr -P -e ssh --exclude=/path/to/exclude/* user@ipaddress:/home/path/to/copy /home/user/www 

build议?

这里的问题很可能与rsync中excludefilter的path有关。

rsync文件列表中使用的path是对于SOURCEpath的。

这就是如果你的目录结构是

  /home/path/to/copy | files_to_copy | file1 \ file2 \ files_to_exclude | file3 \ file4 

那么如果你发出这个命令

 rsync -avr -e ssh user@host:/home/path/to/copy \ /home/user/www --exclude='files_to_exclude/*' 

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

  /home/user/www | files_to_copy | file1 \ file2 \ files_to_exclude 

如果您不想在副本中拥有目录files_to_exclude ,则可以使用以下命令:

 rsync -avr -e ssh user@host:/home/path/to/copy \ /home/user/www --exclude='files_to_exclude' 

我们使用类似的东西

 filename=`date +%F`_backup rsync --verbose --log-file=/backup_logs/"$filename" --progress --stats --compress --rsh=/usr/bin/ssh --recursive --times --perms --links --delete --exclude '*.zip' user@remoteMachine:/data/documents/ /local/data/documents/