问题
I am currently running an rsync command to backup my specific folder.
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.
Can someone shine some light on this for me?
回答1:
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.
--exclude "generator/" --exclude "server/lib/personas_constants.php" --exclude "server/lib/connect.php"
Fixed my issues.
回答2:
Personally I've had better luck using an exclude file. It was quite some time ago but it might be worth a shot.
回答3:
The --exclude
argument takes a pattern, and file names that match that pattern are excluded - not the specific path to a file.
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.
来源:https://stackoverflow.com/questions/8720234/rsync-exclude-not-excluding-specific-files