我运行这个 cmd 来备份我的文件夹:
$ rsync -av --exclude {/mnt/dati/Film/, /mnt/dati/Scout/} --delete /mnt/dati/ /media/cirelli/HD1TB/backup/dati
sending incremental file list
Run Code Online (Sandbox Code Playgroud)
rsync 的答案是:
rsync: link_stat "/mnt/dati/Scout/}" failed: No such file or directory (2)
Run Code Online (Sandbox Code Playgroud)
但是“Scout”目录存在!无法理解我的错误。即使胶片被复制,即使没有任何错误信息!我执行 rsync 时出了什么问题?
非常感谢各位
(哦,我已经阅读了 man https://download.samba.org/pub/rsync/rsync.html和示例http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/但还是想办法解决..!)
我也试过(这被 CTRL+C 打断了):
cirelli@asus:~$ rsync -av --exclude /mnt/dati/Film/ --exclude /mnt/dati/.Trash-1000/ --delete /mnt/dati/ /media/cirelli/HD1TB/backup/dati
sending incremental file list
deleting Documenti/script/
rsync: readlink_stat("/media/cirelli/HD1TB/backup/dati/Documenti/RPi/.2015-05-05-raspbian-wheezy.zip.2sXers") failed: Input/output error (5)
deleting Documenti/RPi/KODI/
deleting Documenti/RPi/berryboot-20130908.zip
deleting Documenti/RPi/2015-05-05-raspbian-wheezy.zip
IO error encountered -- skipping file deletion
.Trash-1000/files/
.Trash-1000/files/2015-05-05-raspbian-wheezy.zip
.Trash-1000/files/berryboot-20130908.zip
.Trash-1000/files/settembre 12.img
^Crsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(632) [sender=3.1.1]
rsync: [sender] write error: Broken pipe (32)
Run Code Online (Sandbox Code Playgroud)
第一个问题是在你的大括号扩展中{},它是由外壳完成的,rsync只是使用结果。
您所做的括号扩展的通过引入空间的目录名之间,所以无操作rsync的--exclude选项已经成为:
--exclude {/mnt/dati/Film/,
Run Code Online (Sandbox Code Playgroud)
所以 rsync 将排除文件(或目录){/mnt/dati/Film/,(假设没有这样的文件)并且它/mnt/dati/Scout/}已经成为要复制的源文件rsync并且没有这样的文件/目录,因此出现错误消息。
要解决这个大括号扩展问题,您需要删除目录名称之间的空格:
{/mnt/dati/Film/,/mnt/dati/Scout/} ....
Run Code Online (Sandbox Code Playgroud)
或者更好地只使用公共部分一次:
/mnt/dati/{Film/,Scout/} ....
Run Code Online (Sandbox Code Playgroud)
但这并不能解决问题,rsync因为--exclude采用了如下模式:
--exclude='foo*bar'
Run Code Online (Sandbox Code Playgroud)
或者
--exclude 'foo*bar'
Run Code Online (Sandbox Code Playgroud)
所以在这种情况下,该目录/mnt/dati/Scout/仍将被视为要从中复制的源目录。
要解决此问题,您也可以使用多个--exclude:
rsync -av --exclude=/mnt/dati/Film/ --exclude=/mnt/dati/Scout/ ....
Run Code Online (Sandbox Code Playgroud)
或将模式保存在文件中并使用:
rsync -av --exclude-from=/file/with/patterns ....
Run Code Online (Sandbox Code Playgroud)