Linux rsync --exclude 不排除特定文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8720234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rsync --exclude not excluding specific files
提问by lockdown
I am currently running an rsync command to backup my specific folder.
我目前正在运行 rsync 命令来备份我的特定文件夹。
Here is the command:
这是命令:
rsync -rtzv -e --exclude "generator/" --exclude "workspace/gallery/server/lib/personas_constants.php" /home/brandon/workspace/gallery /home/brandon/workspace/gallery2
The issue I am having is the --exclude is not excluding the specific files. It is the relative path to the files from where I am running the rsync command. The exclude does however work for the "generator/" directory.
我遇到的问题是 --exclude 不排除特定文件。它是我运行 rsync 命令的文件的相对路径。然而,排除确实适用于“generator/”目录。
Can someone shine some light on this for me?
有人可以为我解释一下吗?
采纳答案by lockdown
It turned out that it is the relative path from the folders that are being rsync'd with one another. Not from where you are running the rsync command.
事实证明,它是相互同步的文件夹的相对路径。不是从您运行 rsync 命令的位置。
--exclude "generator/" --exclude "server/lib/personas_constants.php" --exclude "server/lib/connect.php"
Fixed my issues.
修复了我的问题。
回答by tommyo
Personally I've had better luck using an exclude file. It was quite some time ago but it might be worth a shot.
就个人而言,我使用排除文件运气更好。这是很久以前的事了,但可能值得一试。
回答by Kristian Glass
The --exclude
argument takes a pattern, and file names that match that pattern are excluded - not the specific path to a file.
该--exclude
参数采用一个模式,并排除与该模式匹配的文件名 - 而不是文件的特定路径。
If you don't have any other files called personas_constants.php
, then --exclude personas_constants.php
should do the trick - otherwise you'll have to do something fiddly including --exclude-from
and moving some files around.
如果您没有任何其他名为 的文件personas_constants.php
,那么--exclude personas_constants.php
应该解决问题 - 否则您将不得不做一些繁琐的事情,包括--exclude-from
和移动一些文件。